Web Development



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.

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.

Gives today's date. Date$() gives it as a string. There is also a Date command which sets the system date.
Gives the day of the month (1 .. 31) of <date>.
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.
Returns the hour of <time> as a number from 0 to 23.
Returns the minute of <time> as a number from 0 to 59.
Returns the month number of <date>.
Returns the current date and time.
Returns the second of <time> as a number from 0 to 59.
Returns the current time. Time$()gives it as a string. There is also a Time command which sets the system time.
Gives the day of the week as a number from 1 to 7.
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
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.

Related Discussions

Related Forums