Re: #PERSONAL# Reg: date going as 01/01/0001 - Mailing list pgsql-general

From Karsten Hilbert
Subject Re: #PERSONAL# Reg: date going as 01/01/0001
Date
Msg-id 20150306100742.GB2843@hermes.hilbert.loc
Whole thread Raw
In response to Re: #PERSONAL# Reg: date going as 01/01/0001  (Medhavi Mahansaria <medhavi.mahansaria@tcs.com>)
List pgsql-general
On Fri, Mar 06, 2015 at 03:24:28PM +0530, Medhavi Mahansaria wrote:

> aml_db=> \d+ check_date
>                                  Table "public.check_date"
>   Column   |            Type             | Modifiers | Storage | Stats
> target | Description
> -----------+-----------------------------+-----------+---------+--------------+-------------
>  some_date | date                        |           | plain   |    |
>  sno       | integer                     |           | plain   |    |
>  new_date  | timestamp without time zone |           | plain   |    |
> Has OIDs: no
>
>
> aml_db=> select * from check_date;
>  some_date | sno | new_date
> -----------+-----+----------
> (0 rows)
>
>
> aml_db=> insert into check_date values
> (to_date('','yyyymmddhh24miss'),1,to_date('','yyyymmddhh24miss'));
> INSERT 0 1
> aml_db=> select * from check_date;
>    some_date   | sno |        new_date
> ---------------+-----+------------------------
>  01/01/0001 BC |   1 | 01/01/0001 00:00:00 BC
> (1 row)
>
>
> I need to enter NULL as my date. but since I am getting these variables
> into the bind variables as empty string that is this issue is happening.

You might attach a BEFORE trigger turning ''s into NULLs.

Karsten
--
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346


pgsql-general by date:

Previous
From: Bill Moran
Date:
Subject: Re: #PERSONAL# Reg: date going as 01/01/0001
Next
From: Medhavi Mahansaria
Date:
Subject: Re: #PERSONAL# Reg: date going as 01/01/0001