Question

Locked

Access Date Question

By shurt ·
I have a query in Access that I want to show me the past 24 hours, starting with the last hour and going back 24. I've tried =Date()-1 and that shows me yesterday, but not what I need. If anyone could help I'd greatly appreciate it. Thanks.

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

This might help you...

Access Date Functions

This list gives a brief description of the most useful date functions in Access. Access Help gives more details and will describe exactly how these functions operate in your version of Access.
Note that functions are always followed by a pair of brackets even if - like Date() - there's nothing in them. The Access editor will sometimes remove these brackets but by entering them you are telling Access that you are attempting to use a function.

Date()
Gives today's date. Date$() gives it as a string. There is also a Date command which sets the system date.
Day(<date&gt
Gives the day of the month (1 .. 31) of <date>.
DateAdd(<interval>,<number>,<date&gt
Adds an interval to <date>. The intervals can be anything from seconds to years.
DateDiff(<interval>, <date1>, <date2&gt
Subtracts <date2> from <date1> and gives the result in the unit specified as <interval>.
DatePart(<interval>, <datetime&gt
Extracts part of <datetime>, for example the minute, week or quarter.
Format(<datetime>, <format&gt
Returns <datetime> as a text string in the format specified.
Hour(<time&gt
Returns the hour of <time> as a number from 0 to 23.
Minute(<time&gt
Returns the minute of <time> as a number from 0 to 59.
Month(<date&gt
Returns the month number of <date>.
Now()
Returns the current date and time.
Second(<time&gt
Returns the second of <time> as a number from 0 to 59.
Time()
Returns the current time. Time$()gives it as a string. There is also a Time command which sets the system time.
WeekDay(<date&gt
Gives the day of the week as a number from 1 to 7.
Year(<date&gt
Returns the year number of <date>.


Please post back if you have any more problems or questions.

Collapse -

Depends on what you mean by last hour, ...

by Tony Hopkinson In reply to Access Date Question

Select * from MyTable
Where
DateDiff(hour,Date(),MyDateField) < 24

should give you a start.

It's the number of whole hours though, so
DateDiff(minute,Date(),MyDateField) < (24 * 60), might do you better.

Back to Web Development Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums