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

DayNumberOfYear BUG?

Hello,

I'm using the function DayNumberOfYear and I realized that it count 29th febrary on non-leap years.

For example, on 2011, 28th febrary is the day number 59 and first of march is day number 61.

Is there any way to solve this?

Regards,

Cristian

4 Replies
swuehl
MVP
MVP

Well I don't think it is a bug, because the HELP states:

DayNumberOfYear(date[,firstmonth])

Returns the day number of the year according to a timestamp with the first millisecond of the first day of the year containing date. The function always uses years based on 366 days.

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. If you e.g. want to work with a fiscal year starting March 1, you may specify firstmonth = 3.

Examples:

DayNumberOfYear(date) returns the day number counted from the first of the year.

DayNumberOfYear(date,3) returns the number of the day as counted from the first of March.

As you probably noted, you don't specify a year, so QV takes the "worst case" for calculation.

But you could certainly just subtract today()-yearstart(today()) to get the daynumber (maybe adding 1, to start with 1).

Regards,

Stefan

edit: well, you specify a year giving the date, ok, my mistake

Not applicable
Author

Hello,

Thanks for you quick answer. Your proposed solution much betten that mine.

However, I think if you specified the year (like my case) the funtion should return the correct value. This is the first time I see something like that on a software.

Again, thanks for your time.

Regards,

Cristian

swuehl
MVP
MVP

I essentially agree. Probably there ist some kind of need for a calendar day

indexing function, with constant index per calendar day across years.

I personally have not used it.

Regards,

Stefan

Not applicable
Author

I have encountered this issue also.

Are you using this in the scripting or in the objects themselves? Can you bring in the day of the year from the data source using the native date functions? Is the data coming from a database?