Adding and Subtracting Time

C

cutthroatjess

I have a field called TIME. It is formatted as Date/Time, and "Long Time".
I want to know 10 minutes before, and 10 minutes after the value in Time.
I've tried DateDiff with limited success.
Any Ideas?

Thanks!
 
D

Douglas J. Steele

DateDiff tells you the difference between two values. DateAdd does the
arithmetic...

DateAdd("n", 10, [MyTimeField]) will add 10 minutes, DateAdd("n", -10,
[MyTimeField]) will subtract 10 minutes

BTW, you should rename your field. Time is a reserved word, and you can run
into problems using reserved words for your own purposes. As well, just in
case you weren't aware, even if all you've supplied is a time, the field
will contain a date as well. With no date supplied, Access is going to
assume a date of 30 Dec, 1899.
 
C

cutthroatjess

Worked Great!
Thanks!

I wish I could rename TIME, but it's being converted from a device that uses
that word. Maybe I could import the info under a different name....I'll play
with it.
Thanks again for the advice.
Jesse

Douglas J. Steele said:
DateDiff tells you the difference between two values. DateAdd does the
arithmetic...

DateAdd("n", 10, [MyTimeField]) will add 10 minutes, DateAdd("n", -10,
[MyTimeField]) will subtract 10 minutes

BTW, you should rename your field. Time is a reserved word, and you can run
into problems using reserved words for your own purposes. As well, just in
case you weren't aware, even if all you've supplied is a time, the field
will contain a date as well. With no date supplied, Access is going to
assume a date of 30 Dec, 1899.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



cutthroatjess said:
I have a field called TIME. It is formatted as Date/Time, and "Long Time".
I want to know 10 minutes before, and 10 minutes after the value in Time.
I've tried DateDiff with limited success.
Any Ideas?

Thanks!
 
Top