# New to QlikView

Discussion board where members can get started with QlikView.

Highlighted
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

Tags (3)
1 Solution

Accepted Solutions
MVP

## Re: Re: Error creating day number of year using DayNumberOfYear function

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.

5 Replies
MVP

## Re: Error creating day number of year using DayNumberOfYear function

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

Not applicable

## Re: Error creating day number of year using DayNumberOfYear function

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.

MVP

## Re: Re: Error creating day number of year using DayNumberOfYear function

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

## Re: Error creating day number of year using DayNumberOfYear function

@Nicole Smith: Thank you very much

Not applicable

## Re: Error creating day number of year using DayNumberOfYear function

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