Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Time Calcluations in hh:mm and decimal

Hello All,

I would like to substract two dates which are in "hh:mm:ss a" format.

The output that i would like to get is in hh:mm and also in decimal.

Sample Data: 

Time1:- 09:05:00 AM

Time2:- 11:03:00 AM

Output in hh:mm:- 01:58

Output in decimal:- 1.96

 

What is the best possible way to get this.

 

Any help please.

Mohan V,  

Labels (3)
1 Reply
vapukov
Master II
Master II

Hi,

 

is it time only or datetime?

is it columns or rows?

 

with datetime and columns - it is not hard

if it is time only - need clarify overnight rules

 

in any case

TalendDate.diffDate(myDate,myDate2,"ss") - give number of seconds between dates, than convert seconds to target format or Long

 

 

just a sample for demonstrate:

TalendDate.formatDate("HH:mm",TalendDate.parseDate("ss",String.valueOf(TalendDate.diffDate(TalendDate.parseDate("yyyy-MM-dd HH:mm:ss","2019-05-04 11:40:00"),TalendDate.parseDate("yyyy-MM-dd HH:mm:ss","2019-05-04 11:10:00"),"ss")))) 

same for Long form

TalendDate.diffDate(TalendDate.parseDate("yyyy-MM-dd HH:mm:ss","2019-05-04 11:40:00"),TalendDate.parseDate("yyyy-MM-dd HH:mm:ss","2019-05-04 11:10:00")/60