range of dates in a SQL query

D

D. Stacy

I'm looking for a little help getting this query to return a range of dates.
The query is used as an intermediate step to another query.


PARAMETERS EnterTheDate DateTime;
SELECT EnterTheDate+TimeSerial([Num_Hrs],0,0) AS time_
FROM TblHrsPerDay;

Thanks
 
J

John W. Vinson

I'm looking for a little help getting this query to return a range of dates.
The query is used as an intermediate step to another query.


PARAMETERS EnterTheDate DateTime;
SELECT EnterTheDate+TimeSerial([Num_Hrs],0,0) AS time_
FROM TblHrsPerDay;

Thanks

Please explain. What "range of dates"? What's in your table, and how do you
want to specify the range of dates? What results do you want?
 
D

D. Stacy

The query pulls data from the HrsPerDay table which is a numbers table 1 thru
24; representing each hour of the day.

The subsequent query counts the number of concurrent timed events that took
place during the hour found on this query.

Here is a sample; this Q feeds the next Q that counts the events. I like to
be able to generate several days or a month of these "1 Hour" times.

time_
10/15/08 1:00 AM
10/15/08 2:00 AM
10/15/08 3:00 AM
10/15/08 4:00 AM
10/15/08 5:00 AM
10/15/08 6:00 AM
10/15/08 7:00 AM
10/15/08 8:00 AM
10/15/08 9:00 AM
10/15/08 10:00 AM
10/15/08 11:00 AM
10/15/08 12:00 PM
10/15/08 1:00 PM
10/15/08 2:00 PM
10/15/08 3:00 PM
10/15/08 4:00 PM
10/15/08 5:00 PM
10/15/08 6:00 PM
10/15/08 7:00 PM
10/15/08 8:00 PM
10/15/08 9:00 PM
10/15/08 10:00 PM
10/15/08 11:00 PM
10/16/08 12:00 AM






John W. Vinson said:
I'm looking for a little help getting this query to return a range of dates.
The query is used as an intermediate step to another query.


PARAMETERS EnterTheDate DateTime;
SELECT EnterTheDate+TimeSerial([Num_Hrs],0,0) AS time_
FROM TblHrsPerDay;

Thanks

Please explain. What "range of dates"? What's in your table, and how do you
want to specify the range of dates? What results do you want?
 
J

John W. Vinson

Here is a sample; this Q feeds the next Q that counts the events. I like to
be able to generate several days or a month of these "1 Hour" times.

This can be done easily with the help of a little auxiliary table, which comes
in handy for many things. Create a table Nums with one Long Integer field N;
fill it with values 0 through, oh, 10000 or so (a quick shortcut is to use
Excel, Fill... Series, and copy and paste into Access).

Use a Query based on Nums with a calculated field

TheDate: DateAdd("h", [N], [Enter the date:])

with a criterion

<= [Enter end date]

or, alternatively, a criterion on N of

[How many date points do you want?]
 

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

Similar Threads


Top