• kumar99ms (10/14/2008)


    hi hall

    '19:12:43 CDT 05/23/2007' this is event_date but it is in varchar datatype.

    How can we convert varchar datatype to date time datatype any body plz give suggestion

    You should look at converting these into UTC time, or something based off of a standard time zone. I'm assuming that CDT is Central Daylight time.

    If you were to convert this to UTC time - you'd want to combine the date and time, then cast that as a datetime:

    declare @ts varchar(40)

    set @ts='19:12:43 CDT 05/23/2007'

    select cast(right(@ts,10)+' '+left(@ts, 8) as datetime)

    and then adjust by 5 hours (to get to UTC). Final code would look like:

    declare @ts varchar(40)

    set @ts='19:12:43 CDT 05/23/2007'

    select dateadd(hour,5,cast(right(@ts,10)+' '+left(@ts, 8) as datetime))

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?