Thread: to_date()

to_date()

From
"Paul "
Date:
Can someone explain to me why this happens?
======
select to_date('2002-04-29 07:33:55.000','FXYYYY-MM-DD HH24:MM:SS.MS') as rebill_date;rebill_date 
-------------2004-09-30
======

Ultimatly I'm doing a select into where the original field is of type "character varying".
Doing
======
select fieldname::date as rebill_date
======
generates a "ERROR:  Cannot cast type 'character varying' to 'date'" error, but doing
======
select fieldname::text::date as rebill_date
======
seemes I think I've achieved what I want, but would still be interested in learning about to_date().

Thanks,

Paul
-- 
_______________________________________________
Download the free Opera browser at http://www.opera.com/

Powered by Outblaze


Re: to_date()

From
Kaare Rasmussen
Date:
> Can someone explain to me why this happens?
> ======
> select to_date('2002-04-29 07:33:55.000','FXYYYY-MM-DD HH24:MM:SS.MS') as
> rebill_date; rebill_date
> -------------
>  2004-09-30

If you only want the date:
select to_date('2002-04-29 07:33:55.000','FXYYYY-MM-DD HH24:MI:SS.MS') as 
rebill_date;

If you want the whole thing:
select to_timestamp('2002-04-29 07:33:55.000','FXYYYY-MM-DD HH24:MI:SS.MS') 
as rebill_date;

MM is month
MI is minute

-- 
Kaare Rasmussen            --Linux, spil,--        Tlf:        3816 2582
Kaki Data                tshirts, merchandize      Fax:        3816 2501
Howitzvej 75               Åben 12.00-18.00        Web:      www.suse.dk
2000 Frederiksberg        Lørdag 11.00-17.00       Email: kar@kakidata.dk