Re: How to get CURRENT_DATE in a pl/pgSQL function

From: Jasen Betts <jasen(at)xnet(dot)co(dot)nz>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: How to get CURRENT_DATE in a pl/pgSQL function
Date: 2010-05-19 11:25:57
Message-ID: ht0hs5$i3d$2@reversiblemaps.ath.cx
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On 2010-05-18, Kenneth Marshall <ktm(at)rice(dot)edu> wrote:
> I am trying to write a function that updates the
> date column to the current date. According to:
>
> http://www.postgresql.org/docs/8.4/static/functions-datetime.html#FUNCTIONS-DATETIME-CURRENT
>
> you can use CURRENT_DATE. When I try to use it in
> the following pl/pgSQL function it gives the error:
>
> ERROR: date/time value "current" is no longer supported
> CONTEXT: PL/pgSQL function "merge_data" line 4 at assignment
>
> Here is the code I am using:
>
> CREATE FUNCTION merge_data(key INT, i INT) RETURNS
> VOID AS
> $$
> DECLARE
> curtime date;
> BEGIN
> curtime := 'CURRENT_DATE';

use one of

CURRENT_DATE
'today'
NOW()
CURRENT_TIMESTAMP
'now'

there are probably others which will work too.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Kenneth Marshall 2010-05-19 12:27:14 Re: How to get CURRENT_DATE in a pl/pgSQL function
Previous Message Tim Landscheidt 2010-05-19 11:18:45 Re: How to get CURRENT_DATE in a pl/pgSQL function