Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

time difference formaula 1

Status
Not open for further replies.
Aug 15, 2008
18
GB
Hi,

Newbie .. simple one .. I hope.

I have 2 date/time stamps(start time:x, end time:y). I need to show the result of a formula calculating the different between these date/times (y - x) in the format of date/time ...

Can i find it anywhere ..?

Thanks, in advance.
 
YOu need to use datediff

datediff("n", startdatetime, enddatetime)

This will give difference in mins
"s" will give seconds.

YOu can then use vars to determine days, hours, min etc

local numbervar days;
local numbervar hours;
local numbervar mins;

days:= int(datediff("n", startdatetime, enddatetime)/1440);
hours:= int(remainder(datediff("n", startdatetime, enddatetime),1440))/60;

mins:= int(remainder(datediff("n", startdatetime, enddatetime),60));

totext(days,0,"")&' Days' & totext(hours,0,"")& ' Hours' &
totext(mins,0,"")&' Mins'

Ian


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top