Converting a numeric value to a DateTime

  • 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

  • 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);

  • Lynn,

    That worked perfectly.

    Thank you very much.

    Jeff

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply