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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
jduenyas
Specialist
Specialist

Difference between dates

It must be very simple but I cannot get the result I am looking for:

How do I calculate a difference between dates?

And why this expression :

Day(Monthend(Today())) - Day(Today())

Returns nothing (error)

The expression Day(Monthend(Today()))   correctly returns  31 which is an integer (for this month)

and the expression Day(Today())   correctly returns 27 which is an integer (for today 7/27/13)

But subtracting one from the other returns nothing.

I tried to convert them to numerical value Num(Day(Today()),'###') and Num(Day(Monthend(Today())) ,'###') but that did not work either.

Help?

Thanks

1 Solution

Accepted Solutions
Sokkorn
Master
Master

Hi Josh,

Not sure you try this yet:

Interval(Monthend(Today()) - Today(),'d') or Floor(Monthend(Today()) - Today())

Regards,

Sokkorn

View solution in original post

4 Replies
Sokkorn
Master
Master

Hi Josh,

Not sure you try this yet:

Interval(Monthend(Today()) - Today(),'d') or Floor(Monthend(Today()) - Today())

Regards,

Sokkorn

tresesco
MVP
MVP

The Expression : =Day(Monthend(Today())) - Day(Today())   should work fine(working fine for me). Try that in a  text object. May be you are having issue somewhere else.

dmohanty
Partner - Specialist
Partner - Specialist

Hi Josh,

The above expression will work both in Script and Text Object.

Let V1 = Today();

V2= Day(Monthend(Today())) - Day(Today())


Now V2 will result in 3.


Could you please reply more where and how you want to calculate so that we can help?

jduenyas
Specialist
Specialist
Author

Thank you Sokkorn.

I am not sure if these are the only answers but  your answers (both) returned the right result.

I must say though that after trying some more and enclosing the expression within parenthesis, it did work:

So

Day(Monthend(Today())) - Day(Today())

does not work

But

( Day(Monthend(Today())) - Day(Today()) )

does work.

Peculiar!

Once again , thank you.