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

negative values when calculating number of days

I have two different days in the system. PromisedDeliveryDate and DeliveredDay. I want to calculate how many days that differ between them.

This is the expression I'm usingand it works for the most part. The problem is when I subtract 1 February with 31 January for example. This should give me a result of 1 since it differs 1 day. instead it gives me a result of -30. Does anyone know why?

=interval((day(DeliveredDate)) - (day(PromisedDeliveryDate)), 'D')

1 Solution

Accepted Solutions
tresesco
MVP
MVP

That is because you are asking to subtract 31 from 1. To get your desired result, you just need:
=interval(DeliveredDate - PromisedDeliveryDate, 'D')

'D' format code would take care of the rest.

View solution in original post

2 Replies
tresesco
MVP
MVP

That is because you are asking to subtract 31 from 1. To get your desired result, you just need:
=interval(DeliveredDate - PromisedDeliveryDate, 'D')

'D' format code would take care of the rest.

Magnus
Contributor
Contributor
Author

ty