Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Error creating day number of year using DayNumberOfYear function

Im trying to create the day number of year using DayNumberOfYear function. However, all my dates before year 2000 starts from 2nd of january, and the 1stof january gets the number 366. All days after and including year 2000 gets the right numbers. Is this an error, or am I not using the DayNumberOfYear function correctly.

The issue arised when was creating a master calendar from start date 1950.

Sample:

Date
DayNumberOfYear
01-01-1998366
01-01-1999366
01-01-20001
01-01-20011

Also I have noticed that 01-01-2000 also have DayNumerOfYear = 366

Can anyone help me on this?

Best regards

Philip

1 Solution

Accepted Solutions
Nicole-Smith

Assign the day numbers in the script.  Something like this:

let MinDate = num(makedate(1998,1,1));

let MaxDate = num(makedate(2003,1,1));

Data:

Load Date, if(Month(Date)=1 and Day(Date)=1, 1, PEEK('DayNumberOfYear')+1) as DayNumberOfYear;

Load Date($(MinDate)-1+iterno()) as Date autogenerate 1 While iterno() <= $(MaxDate)+1 - $(MinDate);

let MinDate = null();

let MaxDate = null();

Example file is also attached.

View solution in original post

5 Replies
alexandros17
Partner - Champion III
Partner - Champion III

That function works with year based on 366 days (look at help)

Not applicable
Author

Alessandro Saccone: Thank you for that. So i guess the problem really is how do I get the DayNumberOfYear when I only have 364 days in a year?

The problem is that I have a dataset where the date for an entry is YYYDDD and the largest DDD number is 364.

Nicole-Smith

Assign the day numbers in the script.  Something like this:

let MinDate = num(makedate(1998,1,1));

let MaxDate = num(makedate(2003,1,1));

Data:

Load Date, if(Month(Date)=1 and Day(Date)=1, 1, PEEK('DayNumberOfYear')+1) as DayNumberOfYear;

Load Date($(MinDate)-1+iterno()) as Date autogenerate 1 While iterno() <= $(MaxDate)+1 - $(MinDate);

let MinDate = null();

let MaxDate = null();

Example file is also attached.

Not applicable
Author

@Nicole Smith: Thank you very much

Not applicable
Author

NOTE: The date format YYYYDDD comes from IBM DB2 databases, in case anyone need it.