GETDATE Exspression

  • I have a exspression which I use to get the current date including the file name:

    "Process completed successfully for " + (DT_STR, 4, 1252) YEAR

    ( GETDATE()) + "-" + RIGHT("0" + (DT_STR, 2, 1252) MONTH( GETDATE

    ()), 2) + "-" + RIGHT("0" + (DT_STR, 2, 1252) DAY(GETDATE() ), 2)

    How would I change this to get yesterdays date?

    i.e. GETDATE() -1

    Thanks

  • Have you tried replacing every occurrence of GETDATE() by (GETDATE()-1) ?

    Derek

  • Thanks but that does not work

  • How about using DATEADD(d,-1,GETDATE()) ?

    Derek

  • Nope! :crazy:

  • where the heck are you running that script from? I never saw that before!

  • This is actually a SSIS expression. You would probably have better luck asking in that forum.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • Derek Dongray (2/16/2009)


    How about using DATEADD(d,-1,GETDATE()) ?

    For SSIS, it's DATEADD("d",-1,GETDATE()).

    BTW, I tested this with a flat source file (with 1 line in it), a Derived Column Transform (with the OP's original expression, modified with the above, as a new column) and a flat file as destination. It works fine.

    Process completed successfully for 2009-02-15

    Derek

Viewing 8 posts - 1 through 7 (of 7 total)

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