Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
biswadeep
Contributor
Contributor

inyeartodate Function

Hi all,

I saw people having doubt in InYearToDate function. So here I am describing it please leave a comment on this.

SYNTAX: InYearToDate (timestamp, base_date, period_no[, first_month_of_year])

timestamp: consist of the date field or the date you want to check

base_date: Consist of that date  up-to  which you want the date range should be.

period_no[, first_month_of_year] : Consist of the following value

                                                                        -1 -> Preceding Year

                                                                        0  -> Current Year

                                                                          1 -> Succeeding Year.


Now I will show you one example to describe better:

suppose you have the following data in your Edit Script:

Table1:

Load * inline [

Doj, Name

03/30/2015, Sachin

03/31/2015, Lee

04/01/2016, Rahul

03/30/2016, Raymond

03/31/2016, Virat

04/31/2015, Raunak

02/20/2015, Sahil

];

Table2:

LOAD

Doj,

InYearToDate(Doj,'03/31/2016',0) as CurrentYearFlag,

InYearToDate(Doj,'03/31/2016',-1) as PreviousYearFlag

Resident Table1;



Case1:  InYearToDate (Doj,'03/31/2016',0)


Here the Date period range is from 01/01/2016 to 03/31/2016.

a) if Doj=03/30/2015 (doesn't comes within the date range) hence the value returned is 0(False)

b) if Doj=03/30/2016 (comes within the date range) hence the value returned is -1(True)


Case2:  InYearToDate (Doj,'03/31/2016',-1)


Since -1 indicates previous Year, hence here the Date period range is from 01/01/2015 to 03/31/2015.

a) if Doj=04/20/2015 (doesn't comes within the date range) hence the value returned is 0(False)

b) if Doj=03/30/2015 (comes within the date range) hence the value returned is -1(True)

Case3: InYearToDate (Doj,'03/31/2016',1)

Similarly, Here the Date period range is from 01/01/2017 to 03/31/2017.

1 Solution

Accepted Solutions
Not applicable

It seems the document should be put on "Documents" or "blog posts", but I appreciate it.

View solution in original post

1 Reply
Not applicable

It seems the document should be put on "Documents" or "blog posts", but I appreciate it.