cancel
Showing results for 
Search instead for 
Did you mean: 

Time difference

mohan_salla
Participant
0 Kudos

Hi there,

Could you please help  me on below.

I have 2 fields in my source table:
Login time(varchar)
Logout time(varchar)

I am trying to calculate the difference of both times.

eg:
Login time : 09:17:53
Logout time: 09:53:40


Difference is: 00:35:27


Can anyone help me..

Thanks
Mohan

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi,

try this

lpad( interval_to_char( END_TIME-START_TIME,'HH'),2,0)||':'|| lpad( interval_to_char( END_TIME-START_TIME,'MI')%60,2,0)

||':'||lpad( interval_to_char( END_TIME-START_TIME,'SS')%60,2,0)

mohan_salla
Participant
0 Kudos

Thank you Michael. your answer is helped me...much appreciated for your help. Thank you so much...

Arun, Thank you for your help..

Answers (2)

Answers (2)

mohan_salla
Participant
0 Kudos

Resolved..

Former Member
0 Kudos

Hi,

Easiest way, use this in a SQL transform - SQL Server Forums - Time Subtraction

Else, if you have little time then use substr() and Index() to split it into three and subtract and concatenate later.

Thanks,
Arun