1 Reply Latest reply on Apr 5, 2016 9:08 AM by Jan Post

    Problems with a leap year

    Jan Post

      Hello,

       

      At this moment I am finding some difficulties using a calculated field to analyze differences between today and previous year because of the leap year. I tried the following calculated field however it is not working.

       

       

       

       

       

       

       

      if  [Reporting Date]>#28/02/2016# and [Reporting Date]<#01/01/2017# AND  

       

      dateadd("year",-1,NOW())<[Date] then dateadd("day",2,[Date])

       

      ELSEIF

       

      dateadd("year",-1,NOW())<[Date] then dateadd("day",1,[Date])

       

      elseif dateadd("year",-2,NOW())<[Date] then dateadd("year",1,[Date])

      elseif dateadd("year",-3,NOW())<[Date] then dateadd("year",2,[Date])

      elseif dateadd("year",-4,NOW())<[Date] then dateadd("year",3,[Date])

       

      end

       

      I tried to say that when the leap-time has started at the 29-02-2016 I want to use day 2 instead of day 1 however is not working correct.

       

      Our old query was:

       

       

       

       

       

       

       

      if dateadd("year",-1,NOW())<[Date] then dateadd("day",2,[Date])

       

      elseif dateadd("year",-2,NOW())<[Date] then dateadd("year",1,[Date])

      elseif dateadd("year",-3,NOW())<[Date] then dateadd("year",2,[Date])

      elseif dateadd("year",-4,NOW())<[Date] then dateadd("year",3,[Date])