help about dateadd

  • Hi All,

    I need help about the syntax of the sql as below

    When I try to Execute the tsql as below I get the error message

    declare @IlkTarih datetime

    set @IlkTarih='01.01.2008'

    select dateadd(dd,1,convert(datetime,@IlkTarih,103))

    Msg 242, Level 16, State 3, Line 5

    The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.

    Kind regards

  • I don't think points are valid date separator for style 103.


    N 56°04'39.16"
    E 12°55'05.25"

  • I am able to execute without any problem. I tried on sql server 2005

    See the following code

    declare @a datetime

    set @='01.01.2008'

    select dateadd(dd,1,convert(datetime,@a,103))

  • vyas (1/22/2008)


    I am able to execute without any problem. I tried on sql server 2005

    See the following code

    declare @a datetime

    set @='01.01.2008'

    select dateadd(dd,1,convert(datetime,@a,103))

    This post is in SQL Server 2000 forum ;).

    I tried it in 2000 and it seems to be working. Is it anything related to SET options (Ansi...) etc although i tried that also.

    "Keep Trying"

  • I hate cross posting...

    Anyway, like I said on the other forum, the correct date format number is NOT 103... it's 104. Check out Books Online under CONVERT.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

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

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