Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Convert YYMMDD Date

Author  Topic 

mikefromokc
Starting Member

4 Posts

Posted - 2008-10-07 : 09:38:17
I am fairly new to SQL and I need some help. I have a CHAR field that currently has dates (YYMMDD) in it but I need to convert it to DDMMYY and a date field. What is the proper convert statement?

Thanks in Advance,

Mike

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-07 : 09:48:59

SELECT CONVERT(datetime,charfield) FROM YourTable
will convert it to datetime
Go to Top of Page

mikefromokc
Starting Member

4 Posts

Posted - 2008-10-07 : 09:52:04
I ran this:
SELECT CONVERT(datetime, odcdat) as [Creation Date]
FROM TABLE

I received this error message:

Msg 8115, Level 16, State 2, Line 2
Arithmetic overflow error converting expression to data type datetime.

FYI, ODCDAT is a data type nchar
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-07 : 10:23:43
SELECT CONVERT(datetime, odcdat,12) as [Creation Date]
FROM TABLE
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-10-07 : 10:34:15
quote:
Originally posted by mikefromokc

I am fairly new to SQL and I need some help. I have a CHAR field that currently has dates (YYMMDD) in it but I need to convert it to DDMMYY and a date field. What is the proper convert statement?

Thanks in Advance,

Mike


Always use proper DATETIME datatype and leave the formation to front end application

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

mikefromokc
Starting Member

4 Posts

Posted - 2008-10-07 : 10:58:10
Fixed.

Thanks!!!
Go to Top of Page
   

- Advertisement -