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: 
Neha121
Contributor III
Contributor III

Difference between two dates dates

 

Hi All,

    What is wrong with the code.. I have two dates and I need positive non decimal days between the two dates..

Days between two dates =fabs(date(date#([Date Claim Finalised],'yyyymmdd'),'dd/mm/yyyy') )- fabs(date(date#([Date Claim Notified],'yyyymmdd'),'dd/mm/yyyy'))

 

Neha121_1-1726196639627.png

 

Days between two dates =fabs(num(date#([Date Claim Finalised],'yyyymmdd')))- fabs(num(date#([Date Claim Notified],'yyyymmdd')))

Neha121_2-1726196721328.png

Days between two dates =num(date#([Date Claim Finalised],'yyyymmdd'))- num(date#([Date Claim Notified],'yyyymmdd'))

Neha121_3-1726196805220.png

 

 

 

1 Solution

Accepted Solutions
Vegar
MVP
MVP

When setting the format for dates I always use UPPER case. The reason is M/m.

M=Month

m=minute

(For the date comparisons with the same month value between the two comparing dates the value is correct, but for the rest you will have a decimal value equal to the month number difference, but in seconds.)

You can also simplify your expression a bit. Try this:

=date#([Date Claim Finalised],'YYYYMMDD')- date#([Date Claim Notified],'YYYYMMDD')

View solution in original post

1 Reply
Vegar
MVP
MVP

When setting the format for dates I always use UPPER case. The reason is M/m.

M=Month

m=minute

(For the date comparisons with the same month value between the two comparing dates the value is correct, but for the rest you will have a decimal value equal to the month number difference, but in seconds.)

You can also simplify your expression a bit. Try this:

=date#([Date Claim Finalised],'YYYYMMDD')- date#([Date Claim Notified],'YYYYMMDD')