Date Format

  • Why am I getting the following when running the query below?

    Msg 241, Level 16, State 1, Line 1

    Conversion failed when converting datetime from character string.

    What is a character?

    select top 1 cast(cast(run_date as varchar)as datetime) as run_date into #0 from msdb.dbo.sysjobhistory

    select run_date from #0

    --2011-09-08 00:00:00.000

    if(select run_date from #0) = datename(wk, getdate())

    begin

    print

    'okay'

    end

  • This is resloved. Thanks to @SirSQL 😀

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

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