From: Jasen Betts <jasen@xnet.co.nz>
To: pgsql-sql@postgresql.org
Subject: Re: How to get the previous date?
Date: 17 Oct 2009 11:41:47 GMT
Message-ID: <hbcahr$k31$1@reversiblemaps.ath.cx> (raw)
References: <6caee9520910140240u13daba93ua20637642727776e@mail.gmail.com>
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)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: jasen@xnet.co.nz
Subject: Re: How to get the previous date?
In-Reply-To: <hbcahr$k31$1@reversiblemaps.ath.cx>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox