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

Find difference in time between two points 1

Status
Not open for further replies.

AHint

Programmer
Sep 12, 2003
20
GB
Hi,

I need to find the time difference between datetime fields. DateDiff only appears to give me the days.

The data I am checking will usually be only a couple of hours difference but could potentially be a more than 24 hours. Possibly to complicate matters the second date I am comparing against (ie the later time) could be a null.

Does anybody out there know of a solution??

Thanks
 
You can return the difference in hours in a datediff eg

datediff(h,{mystarttime}, {myendtime}) .

As for the null end time, I would be tempted to use the currentdatetime instead (as long as you warn the user) eg.

datediff(h,{mystarttime}, if isnull({myendtime}) then currentdatetime else {myendtime})

mrees
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top