query failure

  • One of my scheduled job is executing a code

    select convert(datetime,'2005-17-12')

    This code was working till day before yesterday and it  started failing after that. Can anybody guess what could be the reason.

    If something like change in db system configuration will lead to this ?


    subban

  • I believe this is dependent on the client's date formats. Are you set to US dates? It fails on my machine.

  • Someone may have changed the Regional Settings in Control Panel.

    This can be overriden using SET DATEFORMAT, but check the server setting in Control Panel.

    print 'Format is M-D-Y'

    set dateformat mdy

    select convert(datetime,'2005-17-12')

    go

    print ''

    print 'Format D-M-Y'

    set dateformat dmy

    select convert(datetime,'2005-17-12')

     

  • h!!!!,

     

        In your queries and other SQL statements, always represent date in yyyy/mm/dd format. This format will always be interpreted correctly, no matter what the efault date format on the SQL Server is. This also prevents the following error, while working with dates

    regards,

    Vinod S.R( DBA)

    HTC Global Services  

     

     

     

     

     

  • I can't see how it was working two days ago ('2005-15-12') as that date doesn't exist. I would be more willing to believe that it quit working after '2005-12-12' and that '2005-13-12' failed.

    When it worked, are you sure you got the correct values? SQL Server will interpret that as yyyy-mm-dd, so that '2005-11-12' will become November 12, 2005 NOT December 11, 2005.

    -SQLBill

Viewing 5 posts - 1 through 4 (of 4 total)

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