1 Reply Latest reply: Jun 12, 2014 5:00 PM by Nicole Smith RSS

    Can anyone explain how this CURYTD and LastYTD flags work?

      Hi all,

       

      Can anyone please explain how the following lines of code work to get the CURYTD and LastYTD flags in the script?

       

      INYEARTODATE(TempDate, $(vToday), 0) * -1 AS CurYTDFlag,
      INYEARTODATE(TempDate, $(vToday), -1) * -1 AS LastYTDFlag

       

      I am having real trouble understanding the 0 and -1 functions as part of the expression so I am getting really confused.

       

      Any illustrations would be good.

        • Re: Can anyone explain how this CURYTD and LastYTD flags work?
          Nicole Smith

          INYEARTODATE(TempDate, $(vToday), 0) is checking if your date (TempDate) is in the same year (0) as today (vToday).  If it's true it will return -1 and false will return 0.  I'm guessing that's why they are multiplying by -1 in order to work with positive numbers (0 and 1).


          Likewise, INYEARTODATE(TempDate, $(vToday), -1) is checking if your date (TempDate) is in today's (vToday) year - 1 (last year).