Re: Timestamps

From: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>
To: Slavisa Garic <Slavisa(dot)Garic(at)infotech(dot)monash(dot)edu(dot)au>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Timestamps
Date: 2004-02-09 07:28:19
Message-ID: 40273693.8080408@familyhealth.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

  • Timestamps at 2004-02-09 06:34:37 from Slavisa Garic

Browse pgsql-hackers by date

  From Date Subject
Next Message Chris 2004-02-09 07:33:31 Re: RFC: Very large scale postgres support
Previous Message Josh Berkus 2004-02-09 07:27:29 Re: RFC: Very large scale postgres support