pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
How to get the previous date?
5+ messages / 5 participants
[nested] [flat]

* How to get the previous date?
@ 2009-10-14 09:40 Shruthi A <shruthi.iisc@gmail.com>
  2009-10-14 09:43 ` Re: How to get the previous date? Dmitriy Igrishin <dmitigr@gmail.com>
  2009-10-14 10:00 ` Re: How to get the previous date? ramasubramanian <ramasubramanian.g@renaissance-it.com>
  2009-10-14 20:41 ` Re: How to get the previous date? msi77 <msi77@yandex.ru>
  2009-10-17 11:41 ` Re: How to get the previous date? Jasen Betts <jasen@xnet.co.nz>
  0 siblings, 4 replies; 5+ messages in thread

From: Shruthi A @ 2009-10-14 09:40 UTC (permalink / raw)
  To: pgsql-sql

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.

Thanks,
Shruthi

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: How to get the previous date?
  2009-10-14 09:40 How to get the previous date? Shruthi A <shruthi.iisc@gmail.com>
@ 2009-10-14 09:43 ` Dmitriy Igrishin <dmitigr@gmail.com>
  3 siblings, 0 replies; 5+ messages in thread

From: Dmitriy Igrishin @ 2009-10-14 09:43 UTC (permalink / raw)
  To: Shruthi A <shruthi.iisc@gmail.com>; +Cc: pgsql-sql

Hello.

current_date - 1 is the solution.

2009/10/14 Shruthi A <shruthi.iisc@gmail.com>

> 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.
>
> Thanks,
> Shruthi

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: How to get the previous date?
  2009-10-14 09:40 How to get the previous date? Shruthi A <shruthi.iisc@gmail.com>
@ 2009-10-14 10:00 ` ramasubramanian <ramasubramanian.g@renaissance-it.com>
  3 siblings, 0 replies; 5+ messages in thread

From: ramasubramanian @ 2009-10-14 10:00 UTC (permalink / raw)
  To: Shruthi A <shruthi.iisc@gmail.com>; pgsql-sql

Helo Madam,
    Here is the query.
select now()+ interval '-1  day '
Regards,
ram
  ----- Original Message ----- 
  From: Shruthi A 
  To: pgsql-sql@postgresql.org 
  Sent: Wednesday, October 14, 2009 3:10 PM
  Subject: [SQL] How to get the previous date?


  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. 

  Thanks, 
  Shruthi 

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: How to get the previous date?
  2009-10-14 09:40 How to get the previous date? Shruthi A <shruthi.iisc@gmail.com>
@ 2009-10-14 20:41 ` msi77 <msi77@yandex.ru>
  3 siblings, 0 replies; 5+ messages in thread

From: msi77 @ 2009-10-14 20:41 UTC (permalink / raw)
  To: pgsql-sql@postgresql.org,Shruthi A <shruthi.iisc@gmail.com>

Try this:

select cast(mydate as date) -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. 
> Thanks, 
> Shruthi 

Почта со встроенным плеером находится здесь: http://mail.yandex.ru/promo/new/wysiwyg   



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: How to get the previous date?
  2009-10-14 09:40 How to get the previous date? Shruthi A <shruthi.iisc@gmail.com>
@ 2009-10-17 11:41 ` Jasen Betts <jasen@xnet.co.nz>
  3 siblings, 0 replies; 5+ messages in thread

From: Jasen Betts @ 2009-10-17 11:41 UTC (permalink / raw)
  To: 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)
 
 



^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2009-10-17 11:41 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2009-10-14 09:40 How to get the previous date? Shruthi A <shruthi.iisc@gmail.com>
2009-10-14 09:43 ` Dmitriy Igrishin <dmitigr@gmail.com>
2009-10-14 10:00 ` ramasubramanian <ramasubramanian.g@renaissance-it.com>
2009-10-14 20:41 ` msi77 <msi77@yandex.ru>
2009-10-17 11:41 ` Jasen Betts <jasen@xnet.co.nz>

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