YearToDate (or Year2Date) function returns an unexpected value for certain dates but works correctly for other dates in the current year. For example YearToDate(Today()-1,0,1)(check if yesterday belongs to year to date) may return 0 (FALSE) instead of the expected value -1 (TRUE).
According to the help site at yeartodate - script and chart function, Year2Date returns True for all days from 01 Jan of the current year up to and including the date of the last script execution. If the document is reloaded before today, then days between last reload date and today are not counted as year to date.
Environment:
QlikView
Qlik Sense Enterprise on Windows
Resolution:
Since LastReloadTime may vary depending on how the reload tasks are triggered, the best solution is to explicitly instruct YearToDate() function to use today as the boundary. This can be done by setting the last parameter "todaydate" of this function to Today().