Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE

YearToDate function returns unexpected value

No ratings
cancel
Showing results for 
Search instead for 
Did you mean: 
Sonja_Bauernfeind
Digital Support
Digital Support

YearToDate function returns unexpected value

Last Update:

Mar 29, 2022 4:52:38 AM

Updated By:

Sonja_Bauernfeind

Created date:

May 6, 2018 9:00:37 AM

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).

yeartodata check if yesterday belongs to ytd.png
 

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().
 

Labels (1)
Contributors
Version history
Last update:
‎2022-03-29 04:52 AM
Updated by: