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

Subtracting dates

Status
Not open for further replies.

notreconised

Technical User
Jul 21, 2002
14
0
0
GB
on a report i have to boxexs which display a start time and finish time from a table i need to subtract the two dates/times from each other to leave the diferance in hours
ie 14/3 0600 - 16/3 0810 = 50.10Hrs

i have tried subtractin in contoll source but thids makes no calculation for days

thanks for any help in advance
 
You can use DateDiff

eg.

DateDiff("h", date1, date2)

date difference between date1 and date2 in Hours

There are two ways to write error-free programs; only the third one works.
 
Also as long as you have formatted your dates correctly you can do a straight forward subtraction in any field.

i.e. DateDiff = ([enddate]-[startdate])*24

where 24 is number of hoursin day.

This of course won't work for short/long day
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top