Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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,
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