Thread: date function problem

date function problem

From
mohan@physics.gmu.edu
Date:
Hi All
I have an expiration_date column in my table with data type as timestamp.
I need to set that as one year after the current time. how do i do that. I
am getting a casting problem whenever i try something.

something like now()+ 1 year. Please let me know

--mohan




Re: date function problem

From
Larry Rosenman
Date:

--On Tuesday, February 03, 2004 10:51:45 -0500 mohan@physics.gmu.edu wrote:

> Hi All
> I have an expiration_date column in my table with data type as timestamp.
> I need to set that as one year after the current time. how do i do that. I
> am getting a casting problem whenever i try something.
>
> something like now()+ 1 year. Please let me know

ler=# select now()+'1 year';          ?column?
-------------------------------2005-02-03 10:00:40.913383-06
(1 row)

ler=#

ler=# select version();                                           version
---------------------------------------------------------------------------
---------------------PostgreSQL 7.4.1 on i386-portbld-freebsd5.2, compiled by GCC cc (GCC)
3.3.3 [FreeBSD] 20031106
(1 row)

ler=#


> --mohan
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
>                http://www.postgresql.org/docs/faqs/FAQ.html
>



--
Larry Rosenman                     http://www.lerctr.org/~ler
Phone: +1 972-414-9812                 E-Mail: ler@lerctr.org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749

Re: date function problem

From
Tomasz Myrta
Date:
Dnia 2004-02-03 16:51, Użytkownik mohan@physics.gmu.edu napisał:
> Hi All
> I have an expiration_date column in my table with data type as timestamp.
> I need to set that as one year after the current time. how do i do that. I
> am getting a casting problem whenever i try something.
> 
> something like now()+ 1 year. Please let me know

now()+'1 year'::interval

I suggest you reading more about interval datatype in documentation.

Regards,
Tomasz Myrta