Date and Time Summaries

B

Bec_FS

This is a little hard to explain, but here it goes. I have a dataset with
weather data and I get data sent to me every 10 minutes. The date and time
is being stored together such as 14/MAY/2007 12:15:00 AM. etc. However, I
want to base some summaries from say the 14/MAY/2007 at a time starting at
4pm until 7:40am the next morning which would make this the 15/MAY/2007. How
can I get all this data to see each day starting at 4pm one day until 7:40 am
the next day to be a day?
 
J

Jerry Whittle

In the criteria for the date/time field:
Between Date() + #4:00:00 PM# AND Date() + #7:40:00 AM# +1

This will show the data for the current date. If you want to pick a certain
date:

Between [Enter Date]+#4:00:00 PM# And [Enter Date]+#7:40:00 AM#+1

Make sure to go up to Query, Parameters and put in [Enter Date] and make it
Date/Time.
 
J

John Spencer

Adjust the date by subtracting 16 hours.

DateAdd("h",-16,WXDate)

That turns
14 May 2007 04:00:00 PM into 14 May 2007 00:00:00 AM and
15 May 2007 07:40:00 AM into 14 May 2007 03:40:00 PM


Then search against the adjusted date
TimeValue(AdjustedDate) Between #00:00:00# and #15:40:00#


--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
B

Bec_FS

I tried to plug this syntax into the criteria area and when I executed the
query, nothing shows up. Is Date() representing any given date for those
times?

Jerry Whittle said:
In the criteria for the date/time field:
Between Date() + #4:00:00 PM# AND Date() + #7:40:00 AM# +1

This will show the data for the current date. If you want to pick a certain
date:

Between [Enter Date]+#4:00:00 PM# And [Enter Date]+#7:40:00 AM#+1

Make sure to go up to Query, Parameters and put in [Enter Date] and make it
Date/Time.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.

Bec_FS said:
This is a little hard to explain, but here it goes. I have a dataset with
weather data and I get data sent to me every 10 minutes. The date and time
is being stored together such as 14/MAY/2007 12:15:00 AM. etc. However, I
want to base some summaries from say the 14/MAY/2007 at a time starting at
4pm until 7:40am the next morning which would make this the 15/MAY/2007.
How can I get all this data to see each day starting at 4pm one day until 7:40 am
the next day to be a day?
 
J

Jerry Whittle

Hi,

The Date() function shows the system date on your computer when you run it.
Now() shows the date and time. Time() shows, you guessed it, the time!

So it's possible that (1) you don't have any records around the current
date; (1) the system clock on your PC is way off; (3) I wrote the statement
incorrectly; or (4) you have a problem with the Date() function on your
computer. Actually option 4 does happen quite a bit if there is a references
problem. You can check for that plus see if (1) is OK.

With the database open press Ctrl + g on the keyboard.
The Microsoft Visual Basic window should pop up.
Down in the Immediate window type the following and hit Enter:
Debug.Print Date()

That should show you the PCs internal date. (You can also play with Now and
Time). If it's days, weeks, or even years off, that could cause problems. If
you get an error message with Date(), there's probably a references problem.
If so in the VB window go up to Tools, References. There should be at least 4
checked. See if any of the top available references say anything about
Missing. If so, it needs to be fixed.

While in the vicinity, go to Debug on the menu. See if the first entry,
Compile + the database name, is grayed out. If so, good. Things are compiled
properly. If not click on Compile and hopefully there aren't any errors.

--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.

Bec_FS said:
I tried to plug this syntax into the criteria area and when I executed the
query, nothing shows up. Is Date() representing any given date for those
times?

Jerry Whittle said:
In the criteria for the date/time field:
Between Date() + #4:00:00 PM# AND Date() + #7:40:00 AM# +1

This will show the data for the current date. If you want to pick a certain
date:

Between [Enter Date]+#4:00:00 PM# And [Enter Date]+#7:40:00 AM#+1

Make sure to go up to Query, Parameters and put in [Enter Date] and make it
Date/Time.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.

Bec_FS said:
This is a little hard to explain, but here it goes. I have a dataset with
weather data and I get data sent to me every 10 minutes. The date and time
is being stored together such as 14/MAY/2007 12:15:00 AM. etc. However, I
want to base some summaries from say the 14/MAY/2007 at a time starting at
4pm until 7:40am the next morning which would make this the 15/MAY/2007.
How can I get all this data to see each day starting at 4pm one day until 7:40 am
the next day to be a day?
 

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