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

Difference between two dates in days?

Hi everybody.

I have initial date and final date

i have to make the difference, in expression i put final - initial and its working

but i wanna see this in day and hours, how i make this?

1 Solution

Accepted Solutions
Not applicable
Author

timestamp(InitialDate) - timestamp(FinalDate)

View solution in original post

6 Replies
Not applicable
Author

timestamp(InitialDate) - timestamp(FinalDate)

markodonovan
Specialist
Specialist

Hi Jeremias,

Here are a few expressions to try out:

SET date1 = "03/04/2014 01:11:12";

SET date2 = "10/04/2014 23:11:12";

//Get the working days

LET testrange = NetWorkDays('$(date1)','$(date2)')-1;

//Calculate the interval with days

LET rangeinterval = Interval('$(date2)'-'$(date1)','D hh:mm');

//Get the time part of the interval

let varTime = Right( '$(rangeinterval)', 5);

//Get the Days part of the interval

let vartempDays = Left( '$(rangeinterval)', Len( '$(rangeinterval)' ) - 6 );

//Create the correct interval - ie: correct days value

let varTimeBetween = '$(testrange) $(varTime)';

All the best .

Mark

www.techstuffy.com

Not applicable
Author

Good! thank you.

I guess it´s timestamp(final) - timestamp(initial) or am i wrong?

MarcoWedel

Interval([final date]-[initial date], 'dd hh:mm:ss')

Not applicable
Author

Thank you! I guess the timestamp function works too. Am i right?

Cheers

Anonymous
Not applicable
Author

Try it!

=interval(final-initial,'D hh:mm')