Home » SQL & PL/SQL » SQL & PL/SQL » Date Convert
Date Convert [message #37945] Thu, 07 March 2002 13:05 Go to next message
Ed
Messages: 24
Registered: November 1999
Junior Member
Hi, I am trying to check valid dates here.

I have a date value coming from varhchar2 col.
and I want to convert them into DATE(of type 'YYYYMMDD') field.
and I get in the same format, but from varchar col.
can i convert only year if I want,
for example i want to convert this kind of values(i.e., '19850000', 19850200, 19850202).

Thanks In Ad.
Re: Date Convert [message #37946 is a reply to message #37945] Thu, 07 March 2002 15:55 Go to previous messageGo to next message
seng
Messages: 191
Registered: February 2002
Senior Member
Convert varchar2 to date

to_date(varchardate,'yyyymmdd')

i feel that you don't need to convert the only year because it better to convert to date if you want to keep this date and next time you can take the yyyy, dd, mm and so on.

if you want to convert to years only ..

to_date(varchardate,'yyyy')
Re: Date Convert [message #37986 is a reply to message #37945] Tue, 12 March 2002 10:48 Go to previous message
sfhollands
Messages: 15
Registered: October 2001
Junior Member
just ot make it clear
you want to convert the 1st 4 character of the varchar2 column alone to date.

then,

to_date(substr(varchar_dt_col,1,4),'yyyy')
Previous Topic: grouping by 2 sql stts joined by UNION
Next Topic: Default Values !!!!!!!! Urgent
Goto Forum:
  


Current Time: Thu May 09 02:23:39 CDT 2024