Subtract time

J

Janet

I have 2 fields: start time and stop time. I would like
to have a calculated text box that displays the
difference between the start and stop times. I tried: =
[StopTime]-[StartTime], but that doesn't work.

Thanks!
 
G

Guest

Thank you!

Janet
-----Original Message-----
Janet,

Look at the DateDiff function in the Help file.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com


I have 2 fields: start time and stop time. I would like
to have a calculated text box that displays the
difference between the start and stop times. I tried: =
[StopTime]-[StartTime], but that doesn't work.

Thanks!


.
 
D

Diana Criscione

I found this example in another online forum. If your
times span more than one day (ex: StartTime=23:55 and
StopTime=00:15). I've had to use this example in two
different apps and it works like a charm.

([StopTime]-[StartTime]+IIf([StopTime]<[StartTime],1,0))
*24

Diana Criscione
 
J

John Vinson

I found this example in another online forum. If your
times span more than one day (ex: StartTime=23:55 and
StopTime=00:15). I've had to use this example in two
different apps and it works like a charm.

([StopTime]-[StartTime]+IIf([StopTime]<[StartTime],1,0))
*24

Diana Criscione
-----Original Message-----
I have 2 fields: start time and stop time. I would like
to have a calculated text box that displays the
difference between the start and stop times. I tried: =
[StopTime]-[StartTime], but that doesn't work.

A Date/Time value (regardless of format) is stored as a Double Float
number, a count of days and fractions of a day (times) since midnight,
December 30, 1899. As such it doesn't work very well for storing
durations - it's actually best to store just points in time.

The DateDiff() function will return the time between two date/time
values (and if you store the date with the time, it will span one or
multiple midnights with ease). To get the calculated time in miNutes
use

DateDiff("n", [StartTime], [StopTime])

"m" is Months, "n" is miNutes, "h" is hours, etc. - see the online
help in the VBA editor.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top