Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

I have problem with yearend() ?

Hi Community,

  I've problem mwith yearend() function:

  Could you pleae explain this one, how it's working with months and i'm totally confused.

let x= yearend ( '2001-10-19', 0, 12 );

output:2001/11/30

but comming to this part  , it's showing the same year.

let y= yearend ( '2001-10-19', 0,3 );

output:2002/2/28

let z= yearend ( '2001-10-19', 0,4 );

output:2002/3/31

thanks and regards

Satti 

1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

If 2002 starts on 2002/03/01 then in what year does 2002/02/28 fall? It cannot fall in 2002 because that year starts on 2002/03/01. And when should 2001 end? You say it should end on 2001/2/31. Even assuming februari has 31 days then in which year fall the dates between 2001/03/01 and 2002/03/01? Not in 2001 because you say that year ended on 2001/02/31 and not in 2002 because that year starts on 2002/03/01. There's a gap of a year using your logic.


talk is cheap, supply exceeds demand

View solution in original post

9 Replies
Not applicable
Author

hi

YearEnd( )

Returns a value corresponding to a timestamp with the last millisecond of the last date of the year containing date. The default output format will be the DateFormat set in the script. Shift is an integer, where the value 0 indicates the year which contains date. Negative values in shift indicate preceding years and positive values indicate succeeding years. If you want to work with (fiscal) years not starting in January, indicate a value between 2 and 12 in first_month_of_year.

Examples:

yearend ( '2001-10-19' ) returns '2001-12-31' with an underlying numeric value corresponding to '2001-12-31 23:59:59.999'

yearend ( '2001-10-19', -1 ) returns '2000-12-31' with an underlying numeric value corresponding to '2000-12-31 23:59:59.999'

yearend ( '2001-10-19', 0, 4 ) returns '2002-03-31' with an underlying numeric value corresponding to '2002-03-31 23:59:59.999'


Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

let x= yearend ( '2001-10-19', 0, 12 );

The 12 means that the first month of the year is month 12. That means month 11 is the last month of the year. So for date 2001-10-19  the year ends on 2001-11-30.

let y= yearend ( '2001-10-19', 0,3 );

Now month 3 is the first month of the year so march is the first month of the year 2002. That means 2001 ends on march 31 2002.


talk is cheap, supply exceeds demand
tresesco
MVP
MVP

yearend('2001-10-19', 0, 12) - here your first parameter 0 says that there is no shift (in year), second parameter '12' says that your starting month of year is 12, so the end month would be 11 effectively and the last date of the same month (11th) is 30th, hence out put is 2001/11/30 ( that is same year, because there was no shift, and last month is 11).         the same logic implies to all.  hope this explanation helps.

Thanks.

alexandros17
Partner - Champion III
Partner - Champion III

yearend(date, shift, fiscal_year)

where shift and fiscal_year can be null.

if shift has positive values then year considered is the year of the date + shift (the same with negative values.

if fiscal_year is a value different from 1 the year begins in the month specified by fiscal_year value so in your first example with 12 for fiscal year means that your year start in december si it ends in november 30

Hope it helps

er_mohit
Master II
Master II

Hiiiiii

let x= yearend ( '2001-10-19', 0, 12 );

output:2001/11/30

Because it overlap this year month ahead one step like count from 11th month on 12th count gives october then one step ahead so it gives you same year try to put there 15 i m sure it gives you output like below code

but comming to this part  , it's showing the same year.

let y= yearend ( '2001-10-19', 0,3 );

because it count that month for next year you put starts from nov and 3rd one jan one step ahead gives you Feb if here you mention 11 then i m sure it shows the october month for this year means 2001

output:2002/2/28

let z= yearend ( '2001-10-19', 0,4 );

lly like above

output:2002/3/31

Not applicable
Author

For X it is ok ..

  12 is start month . so last month=11

year remains same and no problem.

But ,

comming to Y ,

  start month is 3 , so last month is =2

output should be like  2001/2/31.  but i did not understand why it's showing year=2002?????

Thanks for your reply .

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

If 2002 starts on 2002/03/01 then in what year does 2002/02/28 fall? It cannot fall in 2002 because that year starts on 2002/03/01. And when should 2001 end? You say it should end on 2001/2/31. Even assuming februari has 31 days then in which year fall the dates between 2001/03/01 and 2002/03/01? Not in 2001 because you say that year ended on 2001/02/31 and not in 2002 because that year starts on 2002/03/01. There's a gap of a year using your logic.


talk is cheap, supply exceeds demand
tresesco
MVP
MVP

Think like this:

2001/10/19 belongs to a year. now which year? when the year starts in March(3) then it belongs to a year - 1-Mar-2001 to 28-Feb-2002. So the result - 2002/2/31.

Come back to x =  yearend ( '2001-10-19', 0, 12 )

2001/10/19 belongs to a year. now which year? when the year starts in Dec(12) then it belongs to a year - 1-Dec-2000 to 30-Nov-2001. So the result - 2001/11/30.

Hope this helps.

Not applicable
Author

Thanks Gysbert