Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Expression/ Difference between Date

Hi! How can I calculate the number of days between two dates? For example from 16.04.2013 to 20.08.2013?

Any suggestions greatly appreciated.

Andrea

22 Replies
kiranmanoharrode
Creator III
Creator III

Hi Andrea,

Try Below expression with 2 diffrent fields [ToDate],[FromDate]

=Interval(Date#([ToDate], 'DD.MM.YYYY')-Date#([FromDate],'DD.MM.YYYY'),'D')


Regards,

Kiran Rode

+91 8976977897

Not applicable
Author

Hi! I make an example of what I'm trying to calculate (with different expressions):

Example 1: I calcutate only days between this interval 01.01.2013 to 31.12.2013

- When my start date is 28.10.2012 and my end date is 31.03.2013, the difference is 89 days (01.03.13 - 31.03.13)

- When my start date is 08.09.2013 and my end date is 16.01.2014 the difference is 114 days (08.09.13 - 31.12.13)

- When my start date is 22.09.2002 and my end date is blank, the difference is 365 days (01.01.13 - 31.12.13

Example 2: I calcutate only days between this interval 01.10.2012 to 28.02.2013;

- When my start date is 28.10.2012 and my end date is 31.03.2013, the difference is 123 days (28.10.12 - 28.02.13)

- When my start date is 16.02.2013 and my end date is 16.03.2014 the difference is 12 days (16.02.13 - 28.02.13)

- When my start date is 22.09.2002 and my end date is blank, the difference is 150 days (01.10.12 - 28.02.13)

Do you think it's possible to do?

I really appreciate any help you can provide.

Andrea

Not applicable
Author

Hi Andrea,

If you are expecting to get difference in two dates, following code could help.  

num(makedate(2014, 08, 12)) - num(makedate(2014, 01, 01))

Make dates  using makedate function, convert into number using num function and take a difference.

Thanks,

Arun