Query help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have one table with two 2 fields; one with the date, and another with the
time. I need to be able to capture data for a 24 hour period of time
beginning at 06:30 am in the morning and ending at 06:29:59 in the morning of
next day.
Does anybody have a solution?
 
You'd be far better off storing the date/time as a single field.
Fortunately, you can just add them together.

Assuming you want to prompt for the date, your criteria could be something
like:

WHERE ([DateField] + [TimeField]) BETWEEN (CDate([What Date?]) +
TimeSerial(6, 30, 0)) AND (DateAdd("d", 1, CDate([What Date?])) +
TimeSerial(6, 29, 59))

or

WHERE ([DateField] + [TimeField]) BETWEEN DateAdd("s", 23400, CDate([What
Date?])) AND DateAdd("s", 109799, CDate([What Date?]))
 
This works perfect. Thank you.

Douglas J. Steele said:
You'd be far better off storing the date/time as a single field.
Fortunately, you can just add them together.

Assuming you want to prompt for the date, your criteria could be something
like:

WHERE ([DateField] + [TimeField]) BETWEEN (CDate([What Date?]) +
TimeSerial(6, 30, 0)) AND (DateAdd("d", 1, CDate([What Date?])) +
TimeSerial(6, 29, 59))

or

WHERE ([DateField] + [TimeField]) BETWEEN DateAdd("s", 23400, CDate([What
Date?])) AND DateAdd("s", 109799, CDate([What Date?]))

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Milazimi said:
I have one table with two 2 fields; one with the date, and another with the
time. I need to be able to capture data for a 24 hour period of time
beginning at 06:30 am in the morning and ending at 06:29:59 in the morning
of
next day.
Does anybody have a solution?
 
Back
Top