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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
davinfrost
Contributor III
Contributor III

how to substract a date

how to substract a date

hi guys, i want to ask how to substract a date,

 

for example, 
payment date = 12/12/18 

invoice date =  12/10/18

-i need an interval value between the date.

-in that case we already know, the difference is 2.

[payment date]-[invoice date],

but how to get the value??

 

thank you

1 Solution

Accepted Solutions
tresesco
MVP
MVP

If your date fields are really dates, i.e , number at the back end. You could get the difference in days like:

Interval([payment date]-[invoice date], 'D')

Also subtracting one from another (like Aiolos showed above.) could give you the right number if your date fields don't have timestamp component.

View solution in original post

4 Replies
uacg0009
Partner - Specialist
Partner - Specialist

Hi Davinfrost,
I think you can do it directly.
Use: [payment date]-[invoice date] in your expression or script

Aiolos
phillipmacd
Contributor III
Contributor III

Hi, try

Interval(Date([payment date],'MM/DD/YY') - Date([invoice date],'MM/DD/YY'),'D')

tresesco
MVP
MVP

If your date fields are really dates, i.e , number at the back end. You could get the difference in days like:

Interval([payment date]-[invoice date], 'D')

Also subtracting one from another (like Aiolos showed above.) could give you the right number if your date fields don't have timestamp component.

fallenangel6
Creator
Creator

i convert dates into floor in backend and then use it for finding difference if i dont need to worry about timestamps.

else you can use below format

interval(EndDate -  StartDate,'D hh:mm')

gives output in Day hrs and minute if you have timestamp.