Time calculation help.
I have 2 cols Date in and Date out. the format of the the col is Date IN : 09/10/2001 1:19PM Dateout: 09/11/2001 4:30PM. How can i calculate the time difference between Date in and Date out cols. I need the result on Hr:Mins:Secs. somebody helpFM
May 4th, 2011 11:57am

Declare @d1 datetime, @d2 datetime Select @d1 = '09/10/2001 1:19PM' Select @d2 = '09/11/2001 4:30PM' Select DATEDIFF(hh,@d1,@d2) as [hours], DATEDIFF(mi,@d1,@d2) as [minutes], DATEDIFF(ss,@d1,@d2) as [seconds], convert(varchar,DATEDIFF(ss,@d1,@d2)/3600)+':'+ right('00'+convert(varchar,DATEDIFF(ss,@d1,@d2)%3600/60),2)+':'+ right('00'+convert(varchar,DATEDIFF(ss,@d1,@d2)%3600%60),2)
Free Windows Admin Tool Kit Click here and download it now
May 4th, 2011 12:36pm

Thank you shah. How can i convert this into an expression if i wanted to display the outcome in a text box ?FM
May 4th, 2011 1:59pm

can't you use the field from the query directly?
Free Windows Admin Tool Kit Click here and download it now
May 4th, 2011 3:59pm

Nope i have a listbox based report and i have a view which is my report dataset.FM
May 5th, 2011 2:19pm

You ca use the above expression in your view. Do you have a table in your listbox?
Free Windows Admin Tool Kit Click here and download it now
May 5th, 2011 3:21pm

Nope i am not using a table in my list box.FM
May 5th, 2011 4:14pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics