Skip to main content

yeartodate - script and chart function

This function finds if the input date falls within the year of the date the script was last loaded, and returns True if it does, False if it does not.

Syntax:  

YearToDate(timestamp [ , yearoffset [ , firstmonth [ , todaydate] ] ])

 

Return data type: Boolean

If none of the optional parameters are used, the year to date means any date within one calendar year from January 1 up to and including the date of the last script execution.

Arguments:  

YearToDate arguments
Argument Description
timestamp The date to evaluate as a timestamp or expression resolving to a timestamp, to convert, for example '2012-10-12'.
yearoffset

By specifying a yearoffset, yeartodate returns True for the same period in another year. A negative yearoffset indicates a previous year, a positive offset a future year. The most recent year-to-date is achieved by specifying yearoffset = -1. If omitted, 0 is assumed.

firstmonth

By specifying a firstmonth between 1 and 12 (1 if omitted) the beginning of the year may be moved forward to the first day of any month. For example, if you want to work with a fiscal year beginning on May 1, specify firstmonth = 5.

todaydate By specifying a todaydate (timestamp of the last script execution if omitted) it is possible to move the day used as the upper boundary of the period.

Examples and results:  

The following examples assume last reload time = 2011-11-18

Examples and results
Example Result
yeartodate( '2010-11-18') returns False
yeartodate( '2011-02-01') returns True
yeartodate( '2011-11-18') returns True
yeartodate( '2011-11-19') returns False
yeartodate( '2011-11-19', 0, 1, '2011-12-31') returns True
yeartodate( '2010-11-18', -1) returns True
yeartodate( '2011-11-18', -1) returns False
yeartodate( '2011-04-30', 0, 5) returns False
yeartodate( '2011-05-01', 0, 5) returns True

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!

Join the Analytics Modernization Program

Remove banner from view

Modernize without compromising your valuable QlikView apps with the Analytics Modernization Program. Click here for more information or reach out: ampquestions@qlik.com