From rocampos@bry-it.com Fri May 15 23:21:52 2026 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t3aM2-00DPau-93 for pgsql-general@arkaria.postgresql.org; Wed, 23 Oct 2024 12:20:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1t3aM0-009FH3-7g for pgsql-general@arkaria.postgresql.org; Wed, 23 Oct 2024 12:20:44 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t3D6a-00GfJg-7K for pgsql-general@lists.postgresql.org; Tue, 22 Oct 2024 11:31:16 +0000 Received: from lvps91-250-99-172.dedicated.hosteurope.de ([91.250.99.172]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t3D6X-002Nno-VA for pgsql-general@lists.postgresql.org; Tue, 22 Oct 2024 11:31:15 +0000 Received: from HAPPIX (bry-it.net [37.24.105.49]) by lvps91-250-99-172.dedicated.hosteurope.de (Postfix) with ESMTPSA id EA35EF954F for ; Tue, 22 Oct 2024 13:28:55 +0200 (CEST) From: "Rossana Ocampos" To: Subject: CURRENTE_DATE Date: Tue, 22 Oct 2024 13:31:12 +0200 Message-ID: <00b001db2475$e6584640$b308d2c0$@bry-it.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_00B1_01DB2486.A9E275D0" X-Mailer: Microsoft Outlook 14.0 Thread-Index: AdskdSJYU0pa1txXTxCphvgijCaIWw== Content-Language: de List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multipart message in MIME format. ------=_NextPart_000_00B1_01DB2486.A9E275D0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 Please could you help me, thank you very much. Rossana ------=_NextPart_000_00B1_01DB2486.A9E275D0 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

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

 

Please could you help me, thank you very = much.

Rossana

------=_NextPart_000_00B1_01DB2486.A9E275D0-- From rshepard@appl-ecosys.com Fri May 15 23:22:59 2026 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t3aoL-00DSsL-K7 for pgsql-general@arkaria.postgresql.org; Wed, 23 Oct 2024 12:50:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1t3aoI-009TdV-L1 for pgsql-general@arkaria.postgresql.org; Wed, 23 Oct 2024 12:49:59 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t3aoI-009TdJ-A9 for pgsql-general@lists.postgresql.org; Wed, 23 Oct 2024 12:49:58 +0000 Received: from mail.appl-ecosys.com ([50.126.108.78]) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t3aoG-002SDq-5Z for pgsql-general@lists.postgresql.org; Wed, 23 Oct 2024 12:49:57 +0000 Received: from salmo.appl-ecosys.com (salmo.appl-ecosys.com [192.168.55.1]) by mail.appl-ecosys.com (Postfix) with ESMTP id 322D82A14D6 for ; Wed, 23 Oct 2024 05:49:54 -0700 (PDT) Date: Wed, 23 Oct 2024 05:49:54 -0700 (PDT) From: Rich Shepard To: pgsql-general@lists.postgresql.org Subject: Re: CURRENTE_DATE In-Reply-To: <00b001db2475$e6584640$b308d2c0$@bry-it.com> Message-ID: References: <00b001db2475$e6584640$b308d2c0$@bry-it.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, 22 Oct 2024, Rossana Ocampos wrote: > 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. > 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 Rossana, I have several tables with default values, including dates. Change your input's values to `default' (without the quotes.) Regards, Rich From rshepard@appl-ecosys.com Fri May 15 23:23:28 2026 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t3atj-00DTRq-Pr for pgsql-general@arkaria.postgresql.org; Wed, 23 Oct 2024 12:55:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1t3ath-009YCA-4y for pgsql-general@arkaria.postgresql.org; Wed, 23 Oct 2024 12:55:33 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t3atg-009YC2-Qc for pgsql-general@lists.postgresql.org; Wed, 23 Oct 2024 12:55:33 +0000 Received: from mail.appl-ecosys.com ([50.126.108.78]) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t3ate-002SGO-PN for pgsql-general@lists.postgresql.org; Wed, 23 Oct 2024 12:55:31 +0000 Received: from salmo.appl-ecosys.com (salmo.appl-ecosys.com [192.168.55.1]) by mail.appl-ecosys.com (Postfix) with ESMTP id 6F5382A14D6 for ; Wed, 23 Oct 2024 05:55:29 -0700 (PDT) Date: Wed, 23 Oct 2024 05:55:29 -0700 (PDT) From: Rich Shepard To: pgsql-general@lists.postgresql.org Subject: Re: CURRENTE_DATE In-Reply-To: <00b001db2475$e6584640$b308d2c0$@bry-it.com> Message-ID: <5a32acb0-37fb-f97e-b0fc-6bd560e9eb6@appl-ecosys.com> References: <00b001db2475$e6584640$b308d2c0$@bry-it.com> MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, 22 Oct 2024, Rossana Ocampos wrote: > 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 Rossana, Also, I suggest you put the column names (not their data types) separate from the values. Here's an example of a script I use (Slackware64 linux): \d enforcement Table "public.enforcement" Column | Type | Collation | Nullable | Default ----------------+---------+-----------+----------+-------------- company_nbr | integer | | | action_date | date | | not null | CURRENT_DATE penalty_amount | real | | | reason | text | | | comment | text | | | Foreign-key constraints: "enforcement_company_nbr_fkey" FOREIGN KEY (company_nbr) REFERENCES companies(company_nbr) ON UPDATE CASCADE ON DELETE RESTRICT insert into enforcement (company_nbr, action_date, penalty_amount, reason, comment) values (123, '2024-10-23', default, 'Did a wrong thing.', null); HTH, Rich From ray@rodonnell.ie Fri May 15 23:22:50 2026 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t3bGA-00DVuW-Qv for pgsql-general@arkaria.postgresql.org; Wed, 23 Oct 2024 13:18:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1t3bG8-009iYA-Sv for pgsql-general@arkaria.postgresql.org; Wed, 23 Oct 2024 13:18:45 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from <01020192b98778c0-78365d74-1341-45c8-b0de-cc6b962afcf9-000000@mail.rodonnell.ie>) id 1t3bG8-009iY1-Bq for pgsql-general@lists.postgresql.org; Wed, 23 Oct 2024 13:18:44 +0000 Received: from a7-38.smtp-out.eu-west-1.amazonses.com ([54.240.7.38]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from <01020192b98778c0-78365d74-1341-45c8-b0de-cc6b962afcf9-000000@mail.rodonnell.ie>) id 1t3bG2-002ZXs-D2 for pgsql-general@lists.postgresql.org; Wed, 23 Oct 2024 13:18:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=dv7fx26oobputowqxkzhnujragfvk7eg; d=rodonnell.ie; t=1729689516; h=Content-Type:Message-ID:Date:MIME-Version:Subject:To:References:From:In-Reply-To; bh=cPfhyDLM4aR8hTqXEaeQUD4cVruv09YRVDsY/l6CAvY=; b=vsBH9kZJ085ozJ1N91GmtpczjK+j9kaY53RDyvrFRb+4eEWZVxPr/KkuTx2ryNts jCEmDMFdPAcXtW+4j7qiWr7Cb6ObTFWldELJzuURju1Zw/wmedMeHKvHTKAthshV+6H KSJdKCU2p/c4v7Ild2EXnL9tO1SFQx/pFKb0chah44p7XlxywPDCTz+3phRk2pU9sfs dTdgWVonxNGUdl1CuHTOh7jO8vbRE6Mdr9sYaGCi7SX1f1iZHjnEyBLygsBu3mM7VZl +t9p/wy76OKgS5LWcFFCIJ5DZmt4jjr1PwNy1rIYdtU3cpipC0RRVEjzA7NLcLgJwVN PB3boWYhKA== DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=uku4taia5b5tsbglxyj6zym32efj7xqv; d=amazonses.com; t=1729689516; h=Content-Type:Message-ID:Date:MIME-Version:Subject:To:References:From:In-Reply-To:Feedback-ID; bh=cPfhyDLM4aR8hTqXEaeQUD4cVruv09YRVDsY/l6CAvY=; b=fxUJpb+Q7EX9Hhllr4hlS815DAOfhD65ufRXiSDVy7qhoPdm8yxKVb4GXigu/xk4 m4gjugfg+j0xVqyu1tITFr/rGj2IjMFrxrGN0/lrAqfv+CmKXihOggcbelr4J9GMGRt yu9N0uXFmckCzbgYzhghIXUAKSvQoqGXGSFSphYI= Content-Type: multipart/alternative; boundary="------------NlwdQKVJb5gaZU2G4KJDDsnf" Message-ID: <01020192b98778c0-78365d74-1341-45c8-b0de-cc6b962afcf9-000000@eu-west-1.amazonses.com> Date: Wed, 23 Oct 2024 13:18:36 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: CURRENTE_DATE To: Rossana Ocampos , pgsql-general@lists.postgresql.org References: <00b001db2475$e6584640$b308d2c0$@bry-it.com> Content-Language: en-GB From: Ray O'Donnell In-Reply-To: <00b001db2475$e6584640$b308d2c0$@bry-it.com> X-Spam-Bar: / Feedback-ID: ::1.eu-west-1.Bw1eu/7Uepg3xcsiFBL71JJRCh2A2yTFrgBhhiulXmU=:AmazonSES X-SES-Outgoing: 2024.10.23-54.240.7.38 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------NlwdQKVJb5gaZU2G4KJDDsnf Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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 // Ireland ray@rodonnell.ie --------------NlwdQKVJb5gaZU2G4KJDDsnf Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
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 // Ireland
ray@rodonnell.ie
--------------NlwdQKVJb5gaZU2G4KJDDsnf-- From me.mikram@gmail.com Fri May 15 23:22:30 2026 Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t3xYD-00FaZ5-PJ for pgsql-general@arkaria.postgresql.org; Thu, 24 Oct 2024 13:06:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1t3xYB-00346r-D2 for pgsql-general@arkaria.postgresql.org; Thu, 24 Oct 2024 13:06:51 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t3xYA-00346j-Vq for pgsql-general@lists.postgresql.org; Thu, 24 Oct 2024 13:06:51 +0000 Received: from mail-lj1-x229.google.com ([2a00:1450:4864:20::229]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1t3xY9-002jZ0-1V for pgsql-general@lists.postgresql.org; Thu, 24 Oct 2024 13:06:50 +0000 Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2fc96f9c41fso10615291fa.0 for ; Thu, 24 Oct 2024 06:06:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729775207; x=1730380007; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=/Te/aE4Hj9m6ru5i8I5ika4oANqoc8zrUZmc4CHDV2s=; b=JESjilELn8IZTCSHKAoH7TgSYzNTUMYQvIdAHTuV1wrMkM9rlrejN2taVFNXl4J0Qh W0nQ6/P76jPQTcp7M00iL6VNuOvUuUpmhv+DXtKIWtsp655f8VtgTM5a4Q2qBIvLm4MV 5kSDeuiVjOsVWwe9rUNdcECnAWm8soyP/x5VCrJLDfIZUItmS2KsJwIf9pGfwSZ/6DCo hVbjiALXV/TnqcXRuXRTJu8R5dZTjCzwL+TgazQg36JN8v+o4rNPv7/+BJiHX61B5JNa sBC5hHPSZGvgdbaPgKS3Gz5Nqf9+YWUDl1p9LqDntialwkTF8pFgdtSD6iPEctlHTVIC Eiag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729775207; x=1730380007; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/Te/aE4Hj9m6ru5i8I5ika4oANqoc8zrUZmc4CHDV2s=; b=clh0eFo2b4D/eqHqKplek55xMWSSAuvnUNDmiKb1q8/nSdYFTYld8yC7p/X7Hfk1ti +dyyxn8/HUXhj+LMOhSTl//7vhoPs7Y9kBoHcxk6Iu52HOcTlZ56hFhoOTxMLZLtIaeX LRWVZ3IQ4Vqn89Zi+WCH9VnHcZ8PbE6gucIjvvKfNHqR4wmFUA8AKStSMEcNrqTFP+Ze QDK5SelNDLyGfCYR1BOQQHwc9H3+H2t0WctIGiwB40VbssCdoMes83b/y/VblxUWNlzD gfKs29O/1xKTvmjB35oO4P41jXKfJVE/jiktM+jE/KU1AHfuoVwfpfrz2qKW+MUaXLPG a58A== X-Forwarded-Encrypted: i=1; AJvYcCXHJeUlCSLMpmrJj0J2/oWcvXOYzFPYueySanIme1kedN+zE5/eb6+m4NKtWFnFRxR+wiPLTUGIXIS3p2s5@lists.postgresql.org X-Gm-Message-State: AOJu0YyIPL/nRM+ipzUaD+VnHWPm10XDOQVW0gwgncmggQZLBdUywoLA RcSZVGstEkN3RiTlxl/xSrN5jFd3LlzwqVhhKDJfqDSgbNwEafBlqiyE9BNueePRzgjb+ov0zEO s3S2qI8aC0oz4FSrWZggEVPKbTsA/cbTn X-Google-Smtp-Source: AGHT+IEKZizi65RuGbTQPJEfLzaJuCTP1Fd5JCsmnOfAESlGt/xWwnfw7GgkAj7d2gm5wnqQ2AMgxSyLHruz1J1OOVI= X-Received: by 2002:a17:907:3d89:b0:a9a:eeb:b26a with SMTP id a640c23a62f3a-a9ad199c380mr207746966b.1.1729774882074; Thu, 24 Oct 2024 06:01:22 -0700 (PDT) MIME-Version: 1.0 References: <00b001db2475$e6584640$b308d2c0$@bry-it.com> <01020192b98778c0-78365d74-1341-45c8-b0de-cc6b962afcf9-000000@eu-west-1.amazonses.com> In-Reply-To: <01020192b98778c0-78365d74-1341-45c8-b0de-cc6b962afcf9-000000@eu-west-1.amazonses.com> From: Muhammad Ikram Date: Thu, 24 Oct 2024 18:01:09 +0500 Message-ID: Subject: Re: CURRENTE_DATE To: "Ray O'Donnell" Cc: Rossana Ocampos , pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000633668062538995e" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000633668062538995e Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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=3D# create table date_test (id int, hiredate date default current_date)= ; CREATE TABLE edb=3D# insert into date_test values (1, *default*); INSERT 0 1 edb=3D# 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=E2=80=AFPM Ray O'Donnell wr= ote: > 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: =E2=80=9CCURRENT_DATE=E2=80=9D= LINE 1: > ...extsupplydate ('1085018'::bigint, '5278'::bigint, 'CURRENT_D... ^ ERRO= R: > invalid input syntax for type date: =E2=80=9CCURRENT_DATE=E2=80=9D SQL st= atus: 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@rodonnell.ie > > --000000000000633668062538995e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

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


edb=3D# create table date_test (id int= , hiredate date default current_date);
CREATE TABLE
edb=3D# insert in= to date_test values (1, default);
INSERT 0 1
edb=3D# select * = from date_test;
=C2=A0id | =C2=A0 =C2=A0 =C2=A0hiredate
----+--------= ------------
=C2=A0 1 | 24-OCT-24 00:00:00
(1 row)

=
Regards,
Ikram


On Wed, Oct 23, 202= 4 at 6:18=E2=80=AFPM Ray O'Donnell <ray@rodonnell.ie> wrote:
=20 =20 =20
On 22/10/2024 12:31, Rossana Ocampos wrote:
=20 =20 =20

Hello ,

I am new with PostgreSQ= L 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 =C2=A0DATE DEFAULT CURRENT_DATE, but I get the following error.

=C2=A0

El error <= u>

ERROR: invalid input syntax for type date: =E2=80=9CCURRENT_DATE=E2=80=9D LINE 1: ...extsupplydate ('1085018'::bigint, '5278'::bi= gint, 'CURRENT_D... ^ ERROR: invalid input syntax for type date: =E2=80=9CCURRENT_DATE=E2=80=9D SQL status: 22007 Characters: 78=


I think you just need to leave off the quotes, as current_date is a function:

=C2=A0 insert into .... values ( ... , current_date, ....);

Also, you don't need to quote the bigint values.


HTH,

Ray.


=C2=A0

Please could you help me, thank you very much.

Rossana <= /span>



--=20
Raymond O'Donnell // Galway // Ireland
ray@rodonnell.ie<=
/pre>
  
--000000000000633668062538995e--