View Single Post

   
  #4 (permalink)  
Old 03-01-2008, 02:40 PM
David Portas
 
Posts: n/a
Default Re: Convert CHAR YYYYMMDD to mm/dd/yyyy

"rdraider" <rdraider@sbcglobal.net> wrote in message
news:5_nzi.11029$3x.7225@newssvr25.news.prodigy.ne t...
> Correction the source field in an INT type
> So how to convert INT type YYYYMMDD to a date mm/dd/yyyy
>
>



DECLARE @dt INT;
SET @dt = 20070823;

SELECT CAST(CAST(@dt AS CHAR(8)) AS DATETIME) AS dt;

--
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/m...S,SQL.90).aspx
--


Reply With Quote