If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > SQl info for Time Query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-06-04, 03:15
keiths keiths is offline
Registered User
 
Join Date: Jan 2004
Posts: 2
SQl info for Time Query

I have a database called dx_data. There is a field in it called dx_dati that is a date and time field. As a user enters a record in the database, this field is stamped with the system date & time.
What I require is a query to list all the records in the database that are within 30 minutes of the current system time. I am using a Postgres database (fairly new version).
Reply With Quote
  #2 (permalink)  
Old 01-06-04, 05:43
edwinjames edwinjames is offline
Registered User
 
Join Date: Dec 2003
Posts: 74
Re: SQl info for Time Query

select to_char(sysdate,'DD-MON-YYYY HH:MI') normal_time,to_char(sysdate-1/48,'DD-MON-YYYY HH:MI') time_minus_30_mins from dual;

TO_CHAR(SYSDATE,' TO_CHAR(SYSDATE-1
----------------- -----------------
06-JAN-2004 10:40 06-JAN-2004 10:10

Last edited by edwinjames; 01-06-04 at 08:20.
Reply With Quote
  #3 (permalink)  
Old 01-06-04, 09:42
edwinjames edwinjames is offline
Registered User
 
Join Date: Dec 2003
Posts: 74
SELECT * FROM dx_dati WHERE DATE_FIELD => sysdate-1/48

THIS WILL RETURN ALL RECORDS TIMESTAMPED OVER THE PASS HALF HOUR
Reply With Quote
  #4 (permalink)  
Old 01-06-04, 09:46
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 5,171
Quote:
Originally posted by edwinjames
SELECT * FROM dx_dati WHERE DATE_FIELD => sysdate-1/48

THIS WILL RETURN ALL RECORDS TIMESTAMPED OVER THE PASS HALF HOUR
Unfortunately, the poster is using Postgres, not Oracle.
__________________
Tony Andrews
http://tinyurl.com/tonyandrews
Reply With Quote
  #5 (permalink)  
Old 01-06-04, 13:05
keiths keiths is offline
Registered User
 
Join Date: Jan 2004
Posts: 2
Okay, I can see where this may be a problem with postgres. Not sure why, but maybe there is a simpler work around.
Would it be easier to have a query where I get a listing of the most recent 25 entries in the database?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On