Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
elrelrelr
Contributor
Contributor

Why is date created from Calendar box a decimal number and not an integer?

I created two Calendar Objects to update the variables  and vStartDate  and vEndDate. The variables are created in the script by

LET vStartDate =monthstart(today());

LET vEndDate =monthend(today());

When I look at the number representation of the vEndDate, I get a decimal number and not an integer? e.g. if I set both dates to 01.01.2018,  the value of  vStartDate is 43374 and the value of vEndDate is 43374.62... There are no other objects in the document that should affect the variables


Any idea why this is happening?

3 Replies
vishsaggi
Champion III
Champion III

Can you share your sample app where you are seeing this?

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Dates are stored internally as integers.  To change the display format in the Calendar Object, set to Date on the Number format tab.  The raw variable value will still be a date number, but it's still useful in date functions and arithmetic.

For consistency, you may want to use the number format in your script.

LET vStartDate =num(monthstart(today()));

Also, as MonthEnd also returns the time 23:59:59, you probably want to drop the time using floor().

LET vEndDate =floor(monthend(today()));

I'm not sure how you are getting 43374.62. from the Calendar object. .62 indicates you have a time in the value.


-Rob

elrelrelr
Contributor
Contributor
Author

Thanks!

For the record:

I think the problem was the Min Value and Max Value, as theese where derived from a timestamp and and therefore a decimal number. Added the floor(num()) functions both here and in the definition in the script, and it seems that it works correctly now.