Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 24th, 2004, 11:20 AM
sail87 sail87 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 5 sail87 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 31 m 55 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old February 24th, 2004, 12:27 PM
r937's Avatar
r937 r937 is online now
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 18,235 r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level)r937 User rank is General 1st Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 1 Day 15 h 57 m 34 sec
Reputation Power: 1054
Code:
select [Date]
     , [Time]
     , Host
     , Message
  from yourtable
 where datediff("n",[Time],Now()) <= 5

tip: do not use reserved words to name your columns
__________________
r937.com | rudy.ca

pre-order my book Simply SQL from Amazon

Reply With Quote
  #3  
Old February 24th, 2004, 01:04 PM
sail87 sail87 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 5 sail87 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 31 m 55 sec
Reputation Power: 0
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > Filter Query on a time field


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT