Re: How to get the previous date? - Mailing list pgsql-sql

From Jasen Betts
Subject Re: How to get the previous date?
Date
Msg-id hbcahr$k31$1@reversiblemaps.ath.cx
Whole thread Raw
In response to How to get the previous date?  (Shruthi A <shruthi.iisc@gmail.com>)
List pgsql-sql
On 2009-10-14, Shruthi A <shruthi.iisc@gmail.com> wrote:
> --0016e64698e4af821f0475e1f43d
> Content-Type: text/plain; charset=ISO-8859-1
>
> Hi,
>
> I'm using Enterprise DB PostgresPlus version 8.3.
> Is there is a simple function or command like previous_date(mydate) which
> when passed a particular date, simply returns the previous date? I tried
>
> mydate - 1
>
> but this doesnt work.

it should, if mydate is a date variable.

if it's some sort of timestamp more care is needed
mytimestamp - interval'1 day'
also don't use interval'24h' unless you want 24h, because not all days are 24h
select timestamptz'2009-09-28 00:30' - interval'24 h' ;        ?column?         ------------------------  2009-09-26
23:30:00+12 (the interval crosses the local start of DST)
 


pgsql-sql by date:

Previous
From: Rob Sargent
Date:
Subject: Re: Efficiency in Multiple Queries of Same Table in a PL/PgSQL Function
Next
From: Thom Brown
Date:
Subject: Re: Lag and lead window functions order by weirdness