Re: Dateadd

From: Vivek Khera <khera(at)kcilink(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Dateadd
Date: 2001-05-04 14:20:02
Message-ID: x78zkdgprh.fsf@yertle.kciLink.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

>>>>> "LP" == Ligia Pimentel <lmpimentel(at)yahoo(dot)com> writes:

LP> I need to know if there is a sql function implemented in postgres
LP> that gives me a date plus any number of days, months or years (the
LP> traditional dateadd function) or how to do it in sql?

Here's what I use:

select CURRENT_DATE + '4 DAYS'::interval;

Just cast your "interval" from a string to an interval type, then add
it to your date value.

I doubt this is portable. What "tradition" provides for a dateadd()
function?

--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Vivek Khera, Ph.D. Khera Communications, Inc.
Internet: khera(at)kciLink(dot)com Rockville, MD +1-240-453-8497
AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/

In response to

  • Dateadd at 2001-05-03 00:55:39 from Ligia Pimentel

Browse pgsql-sql by date

  From Date Subject
Next Message Jeff Self 2001-05-04 15:50:31 Re: "correct" sorting.
Previous Message D'Arcy J.M. Cain 2001-05-04 11:35:15 Re: How to encode and decode password in pgsql !!