Re: Doing INTERVAL with NOW() versus casted timestamp

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: John Shott <shott(at)stanford(dot)edu>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Doing INTERVAL with NOW() versus casted timestamp
Date: 2013-02-16 16:09:13
Message-ID: 10542.1361030953@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

John Shott <shott(at)stanford(dot)edu> writes:
> I believe that if you use the current_date function, instead of now(),
> and subtract 24 hours from that, then you will get the behavior that you
> expect.

If you're working with dates, rather than timestamps, it's even easier
than that: just add or subtract an integer.

regression=# select current_date;
date
------------
2013-02-16
(1 row)

regression=# select current_date - 1;
?column?
------------
2013-02-15
(1 row)

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Kellerer 2013-02-16 16:17:50 Re: Visual query builder for PosgreSQL?
Previous Message Gauthier, Dave 2013-02-16 16:04:42 Re: Visual query builder for PosgreSQL?