Re: Timestamps - Mailing list pgsql-hackers

From Christopher Kings-Lynne
Subject Re: Timestamps
Date
Msg-id 40273693.8080408@familyhealth.com.au
Whole thread Raw
In response to Timestamps  (Slavisa Garic <Slavisa.Garic@infotech.monash.edu.au>)
List pgsql-hackers
> I wanted to ask a simple question. Say I have a table with the timestamp
> field. What is the best way to say get all the records that were created
> say 2 hours before the query. One of the options would be to generate the
> timestamp in the correct format and then send a query in the format 
> SELECT * from <table> where create_time < <generated_timestamp>
> 
> Is there a better way than this?

Sure is:

SELECT * from <table> where create_time < (CURRENT_TIMESTAMP - INTERVAL 
'2 hours');

Chris



pgsql-hackers by date:

Previous
From: Neil Conway
Date:
Subject: Re: psql tab completion & USERSET vars
Next
From: Josh Berkus
Date:
Subject: Re: RFC: Security documentation