GETDATE -1 Expression

  • 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

  • ...DATEADD( "Day", -1, GETDATE() )

    --Ramesh


  • Or DATEADD("d",-1,GETDATE())

    (I forgot that SSIS needs the quotes).

    Derek

  • Thanks Guys,

    Im how would the whole exspresion look?

    In regards to my code posted abouve?

  • ...Just need to replace GETDATE() with DATEADD( "Day", -1, GETDATE() ) in the expression

    --Ramesh


  • "Process completed successfully for " + (DT_STR,4,1252)[YEAR]([DATEADD]("d",-1,[GETDATE]())) + "-" +

    ("0" + (DT_STR,2,1252)[MONTH]([DATEADD]("d",-1,[GETDATE]())),2) + "-" +

    ("0" + (DT_STR,2,1252)[DAY]([DATEADD]("d",-1,[GETDATE]())),2)

    Derek

  • thanks Derek, worked well!

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

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