By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,339 Members | 1,973 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,339 IT Pros & Developers. It's quick & easy.

Using hours in a date range parameter

P: n/a
I would like to run a query every date to extract only the records that
have been added to the database within my criteria for a 24 hour
period. I.E. I would like the query to extract records from 3:30 pm
yesterday to 3:30 pm today. The query is automated to run at 3:30
everyday. I am unsure of hour to express hours in my date field
parameter.

Thanks in advance!!!

Doug in Tallahassee

Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Something like:

SELECT * FROM table_name
WHERE date_time_column Between DateAdd("h", -24, Date() + #1530#) And
Date() + #1530#

1530 = 3:30 PM.

Between expression translates to "24 hrs before today at 3:30PM and
today at 3:30PM."

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQf/n84echKqOuFEgEQIzmgCgwbnXm1vDIA9HGLvXHUx6Xx+LseYAn 3ql
Y8EI8rHeOzpqi3alDHGilzV9
=dJ2J
-----END PGP SIGNATURE-----
Doug1962 wrote:
I would like to run a query every date to extract only the records that
have been added to the database within my criteria for a 24 hour
period. I.E. I would like the query to extract records from 3:30 pm
yesterday to 3:30 pm today. The query is automated to run at 3:30
everyday. I am unsure of hour to express hours in my date field
parameter.

Nov 13 '05 #2

P: n/a
Criterion for date field:
=DateAdd("d",-1,Date()+TimeValue("13:30")) And

<Date()+TimeValue("13:29:59")

DateAdd gives yesterday's date because its second param (-1)
subtracts one day ("d" first param) from today's date (Date())
at 13:30 pm.

Geoff
Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.