Posted by David Portas on 08/23/07 22:39
"rdraider" <rdraider@sbcglobal.net> wrote in message
news:7Unzi.11028$3x.3766@newssvr25.news.prodigy.net...
>I can't seem to find a method of converting a CHAR(8) column in the form of
>YYYYMMDD to an actual date such as mm/dd/yyyy
>
> Can anyone point me in the right direction?
>
> Thanks
>
'YYYYMMDD' is one of the standard, non-regional formats supported by SQL
Server. No special conversion is necessary:
DECLARE @dt CHAR(8);
SET @dt = '20070823';
SELECT CAST(@dt AS DATETIME) AS dt;
dt
------------------------------------------------------
2007-08-23 00:00:00.000
(1 row(s) affected)
--
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--
Navigation:
[Reply to this message]
|