Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Date/time difference in Minutes in the load script

I am trying to calculate the following in my load script

StartDatetime - FinishDateTime

the difference should be in minutes (dates could be in the same day or few days apart)

I have tried the inerval function, it display the number of minutes but when I try to take average it does conert to small number (0.00xxx)

1 Solution

Accepted Solutions
johnw
Champion III
Champion III


felmasri wrote:the above solution won't get me the minyues when the two dates I am working on are in the same day (where the time difference is less than a day)


Both approaches I mentioned work just fine for me whether the timestamps are on the same day or on different days. See below and attached. Have I misunderstood your requirement?

Edit: Ah, perhaps I confused you when I said that timestamps are stored in days. I didn't mean a whole number of days. That would be a date, not a timestamp. The time portion of a timestamp is stored as a fraction of a day. So today at noon is stored as 40323.5.

View solution in original post

6 Replies
johnw
Champion III
Champion III

Intervals are internally stored as DAYS. If your use of numeric functions has converted it to a number, that number is the number of days. To get minutes, either multiply by 24 * 60, or convert it back to an interval and tell it to display it in minutes.

Not applicable
Author

thanks for your response.

the above solution won't get me the minyues when the two dates I am working on are in the same day (where the time difference is less than a day)

boorgura
Specialist
Specialist

Did you try Timestamp(Timestamp#(EndDateTime) - Timestamp#(StartDateTime), 'hh:mm:ss')

johnw
Champion III
Champion III


felmasri wrote:the above solution won't get me the minyues when the two dates I am working on are in the same day (where the time difference is less than a day)


Both approaches I mentioned work just fine for me whether the timestamps are on the same day or on different days. See below and attached. Have I misunderstood your requirement?

Edit: Ah, perhaps I confused you when I said that timestamps are stored in days. I didn't mean a whole number of days. That would be a date, not a timestamp. The time portion of a timestamp is stored as a fraction of a day. So today at noon is stored as 40323.5.

Not applicable
Author

Thanks John, it works great ...thanks alot.

Kohli
Creator II
Creator II

Hi Jhon, Iam also getting same issue, How can i retrieve the diff bn 2 date fileds in minutes. I have date format like this

Start date,      End date,       Start time,   End time

21/05/2018,    22/05/2018,  23:55:20,     04:25:45

22/05/2018,   22/05/2018,   10:43:25,     15:55:23   ;

 

I want output like

Start date,      End date,       Start time,   End time,  Total_Time

21/05/2018,    22/05/2018,  23:55:20,     04:25:45,     270 Min (approximately)

22/05/2018,   22/05/2018,   10:43:25,     15:55:23