|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Filter Query on a time field
I am trying to query a table in Access by getting only the records added in the last five minutes.
My table has four fields; Date, Time, Host, Message. The time field is the time the event happened and was posted to the database. The format of the time field is 12:34:56 PM. I've tried using: <Time()-5 or >Time()-5 I got these examples from the Date function, but they didn't seem to translate to time. Does anyone have any suggestions? Thanks |
|
#2
|
||||
|
||||
|
Code:
select [Date]
, [Time]
, Host
, Message
from yourtable
where datediff("n",[Time],Now()) <= 5
tip: do not use reserved words to name your columns |
|
#3
|
|||
|
|||
|
I entered the SQL statement and still got an empty return. I increased the time all the way to 7200 and still nothing, yet I know I have entries here in the past half an hour. If I run the query without the time filter I return these entries, but once I put that filter in it comes back blank.
Is this statement configured to represent minutes? Also, what does the "n" represent. Also, my column names are actually quite long, I abbreviated in my example, I won't be so lazy next time. Thanks a lot for your help. |
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > Filter Query on a time field |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|