Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
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).