Re: CURRENTE_DATE

From: Muhammad Ikram <me(dot)mikram(at)gmail(dot)com>
To: "Ray O'Donnell" <ray(at)rodonnell(dot)ie>
Cc: Rossana Ocampos <rocampos(at)bry-it(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: CURRENTE_DATE
Date: 2024-10-24 13:01:09
Message-ID: CAJQ7xG5bxJV0+J-K1Sjxb6bA7j+Vi7smmoww7Z_7ThTgsmmvDA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I am just thinking, when DEFAULT CURRENT_DATE is being used in table
definition then why the function is again being used in INSERT statement
why not use
default. Here is sample

edb=# create table date_test (id int, hiredate date default current_date);
CREATE TABLE
edb=# insert into date_test values (1, *default*);
INSERT 0 1
edb=# select * from date_test;
id | hiredate
----+--------------------
1 | 24-OCT-24 00:00:00
(1 row)

Regards,
Ikram

On Wed, Oct 23, 2024 at 6:18 PM Ray O'Donnell <ray(at)rodonnell(dot)ie> wrote:

> On 22/10/2024 12:31, Rossana Ocampos wrote:
>
> *Hello ,*
>
> I am new with PostgreSQL and I have a bug. I have created a function that
> has an input variable of type date , in case it does not receive value , it
> has to assume by default the current date.
>
> I have defined it as follows variable DATE DEFAULT CURRENT_DATE, but I
> get the following error.
>
>
>
> *El error *
>
> ERROR: invalid input syntax for type date: “CURRENT_DATE” LINE 1:
> ...extsupplydate ('1085018'::bigint, '5278'::bigint, 'CURRENT_D... ^ ERROR:
> invalid input syntax for type date: “CURRENT_DATE” SQL status: 22007
> Characters: 78
>
>
> I think you just need to leave off the quotes, as current_date is a
> function:
>
> insert into .... values ( ... , current_date, ....);
>
> Also, you don't need to quote the bigint values.
>
>
> HTH,
>
> Ray.
>
>
>
>
> Please could you help me, thank you very much.
>
> Rossana
>
>
>
> --
> Raymond O'Donnell // Galway // Irelandray(at)rodonnell(dot)ie
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Greg Sabino Mullane 2024-10-24 14:01:21 Re: Query performance issue
Previous Message Tom Lane 2024-10-24 02:38:59 Re: Using Expanded Objects other than Arrays from plpgsql