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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculate Duration

Status
Not open for further replies.

eebabe

IS-IT--Management
Jul 17, 2003
54
US
I have start Date (7/1/09 - field type date) and start time (0350 - field type string) and end date time (7/2/09 0450 - field type string). I want to find the time duration. I've tried using concatenate to convert 0350 to time but no success in calculating the duration. Pls help.

Thanks.
 
Use DateDiff, which can cope with times as well as dates, and can give the answer in hours, minutes or second.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 10 & 11.5 with Windows XP [yinyang]
 
//{@diff}:
datetimevar stdt;
datetimevar enddt;
stringvar timex := {table.starttime};
stdt := datetime({table.startdate},time(val(left(timex,2)),val(mid(timex,3)),0));
stringvar array strdt := split({table.enddttime},"/");
enddt := datetime(date(2000+val(left(strdt[3],2)),val(strdt[1]),val(strdt[2])), time(val(mid(strdt[3],4,2)),val(mid(strdt[3],6,2)),0));
numbervar diff := datediff("n",stdt,enddt);

This would return the duration in minutes.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top