Datediff not recognised

  • this is my tsql expression: DATEADD(dd, DATEDIFF(dd, 0, GETDATE()) - 1, 0)

    when i try to copy same expression to a variable. It throws error saying datediff not recognised.

    How to write same expression in ssis ?

  • Use the SSIS syntax.

    DATEADD("dd", DATEDIFF("dd", (DT_DATE) "1900-01-01", GETDATE()) - 1, (DT_DATE) "1900-01-01")

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Luis Cazares (8/1/2016)


    Use the SSIS syntax.

    DATEADD("dd", DATEDIFF("dd", (DT_DATE) "1900-01-01", GETDATE()) - 1, (DT_DATE) "1900-01-01")

    Or, use a stored procedure to do the actual work and have SSIS call it. 😉

    --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 3 posts - 1 through 2 (of 2 total)

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