Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Difference between two Dates

Hi All,

I need to find the difference between two dates. For this i used this expression below

 

(

dayStart(timestamp(END)) - dayStart(timestamp(START)))

but how to include the Start and end date also while subtracting

For Example: 

START Date: 24-Feb-2013  and END Date: 2-Mar-2013

If i used the above expression, Result is : 6

But i need the result as 7 (24,25,26,27,28,1,2)

Any idea?

Thanks,

S.Selvakuamr

1 Solution

Accepted Solutions
Gysbert_Wassenaar

Simply add 1 to the result. Or use DayStart for the start date and DayEnd for the end date and round the result: round(dayend(end)-daystart(start))


talk is cheap, supply exceeds demand

View solution in original post

6 Replies
Not applicable
Author

try

Interval() function

example--

Interval(EndDate - StartDate)

Not applicable
Author

Updated code

=Num(date#('2-Mar-2013','D-MMM-YYYY'))+1 - num(date#('24-Feb-2013','D-MMM-YYYY'))


=Num(date#('End','D-MMM-YYYY'))+1 - num(date#('Start','D-MMM-YYYY'))

=date#('End','D-MMM-YYYY')+1 - date#('Start','D-MMM-YYYY')

iNTERVAL(date#('2-Mar-2013','D-MMM-YYYY') - date#('24-Feb-2013','D-MMM-YYYY'),'DD')

hic
Former Employee
Former Employee

Make sure that you have interpreted the fields correctly using Date#() or TimeStamp#() - Not Date() and TimeStamp(). If you have done so, you can just subtract one date from another and the result will be number of days between the two.

Date#(END, 'DD-MMM-YYYY') - Date#(START, 'DD-MMM-YYYY') as Duration

HIC

Not applicable
Author

Thanks HIC but how to include Start and End date...

Let me put this in way, count of days between  Start and end date (Including start and end date)

Selva

Gysbert_Wassenaar

Simply add 1 to the result. Or use DayStart for the start date and DayEnd for the end date and round the result: round(dayend(end)-daystart(start))


talk is cheap, supply exceeds demand
Not applicable
Author

Thanks Gysbert.. "Dayend" does the trick..

Selva