February 25, 2010 at 12:05 pm
I have data coming from an AS400 that stores date and time in a Numeric column. I need to convert this to an actual DateTime column in SQL.
Example:
20100224184500 --> 02/24/2010 18:45:00.000
Does anyone have a solution to this dilema?
Any help would be appreciated.
Thanks,
Jeff
February 25, 2010 at 12:16 pm
Does the following ode help you out?
declare @IntDate bigint,
@CharDate varchar(32);
set @IntDate = 20100224184500;
set @CharDate = CAST(@IntDate as varchar(32));
select @IntDate, @CharDate, cast(stuff(stuff(stuff(@CharDate,13,0,':'),11,0,':'),9,0,' ') as datetime);
February 25, 2010 at 12:24 pm
Lynn,
That worked perfectly.
Thank you very much.
Jeff
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy