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

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
jjustingkm
Creator II
Creator II

Date Difference issue

I am using the below formula to get the date difference between current date and previous month end. But getting incorrect result. looks like the issue is because of $(vMonthEnd) value, when I check this variable value in the script editor, get the correct value (4/30/21), but in the sheet value looks like 6.9657 something. Any help would be appreciated.

$(vMonthEnd)  - currentdate() 

vMonthEnd=date(floor(monthend(addmonths(Today(),-1))), 'MM/DD/YYYY') - now it is 4/30/2021.

 

1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

The problem is that you format the value as a date with format MM/DD/YYYY. If you then dollar expand that value it calculates the result of 4/30/2021, in other words 4 dived by 30 divided by 2021.

Try leaving out the Date() function: floor(monthend(Today(),-1))


talk is cheap, supply exceeds demand

View solution in original post

3 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

The problem is that you format the value as a date with format MM/DD/YYYY. If you then dollar expand that value it calculates the result of 4/30/2021, in other words 4 dived by 30 divided by 2021.

Try leaving out the Date() function: floor(monthend(Today(),-1))


talk is cheap, supply exceeds demand
jjustingkm
Creator II
Creator II
Author

Thanks for the quick response. that worked. Just a quick question, 4/3021 shows as 44316, is this Julian or something?

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

44316 is the number of days since 12/31/1899. It's how lots of computer systems store dates.


talk is cheap, supply exceeds demand