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: 
warrentk80
Creator
Creator

difference between two dates.

Goodmorning everyone

I need to calculate the difference between two dates.

there is a native function in QlikView?

Thanks for collaboration

Andrea

4 Replies
fvelascog72
Partner - Specialist
Partner - Specialist

Try Interval() function.

manojkulkarni
Partner - Specialist II
Partner - Specialist II

try

fabs(Date(Field1,'DD/MM/YYYY')) - fabs(Date(Field2,'DD/MM/YYYY'))

jonathandienst
Partner - Champion III
Partner - Champion III

Dates are numeric values in days, times are fractions of a day, so:

     =Date1 - Date2      // will give number of days (including fractional amount for the time difference if any

     =Floor(Date1) - Floor(Date2)   // number of days disregarding time differences

Also

     =(Date1 - Date2) * 24               // differences in hours

     =(Date1 - Date2) * 24 * 60             // differences in minutes

Interval() can format the day and time differences

     =Interval(Date1 - Date2, 'dd hh:mm')   // displays time differences in hh:mm format


HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
jonathandienst
Partner - Champion III
Partner - Champion III

Manoj K wrote:

fabs(Date(Field1,'DD/MM/YYYY')) - fabs(Date(Field2,'DD/MM/YYYY'))

Date() is a formatting function - it does not affect the value. If Field1 and Field2 are dates, then Date() here will do nothing except waste time. If Field1 and Field2 are strings, then you should use Date#() which is the date interpretation function.

Dates would not usually be negative (unless they are before 31 December 1899), so fabs() will also not do anything useful here.

So if the values are dates, then that expression is the same as =Field1 - Field2

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein