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.
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 |
|
|
mikefromokc
Starting Member
4 Posts |
Posted - 2008-10-07 : 09:52:04
|
I ran this:SELECT CONVERT(datetime, odcdat) as [Creation Date] FROM TABLEI received this error message:Msg 8115, Level 16, State 2, Line 2Arithmetic overflow error converting expression to data type datetime.FYI, ODCDAT is a data type nchar |
|
|
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 |
|
|
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 applicationMadhivananFailing to plan is Planning to fail |
|
|
mikefromokc
Starting Member
4 Posts |
Posted - 2008-10-07 : 10:58:10
|
Fixed.Thanks!!! |
|
|
|
|
|