SSIS - Excel Connection with Week of Year timestamp - 1

  • rjjh78

    SSCrazy

    Points: 2699

    Hello,

    I am working on an SSIS package as to which I would like to create an Excel file with a timestamp with last weeks date number.  The following works:

    "Filename_" + RIGHT((DT_STR,4,1252)DATEPART("ww" ,GETDATE()), 4)  + ".xls"

    Which produces:  Filename_2019_25.xls

    However, we need to make this so that we are able to get Last Weeks' Week Number (instead of this week).

    Desired file name:  Filename_2019_24.xls

    My initial thought was to do getdate()-7, but this does not work.  Does anyone know if/how this might be possible?

    Many Thanks in advance!

     

     

     

  • Phil Parkin

    SSC Guru

    Points: 243485

    Replace

    DATEPART("ww" ,GETDATE())

    with

    DATEPART( "ww", dateadd("d",-7,getdate() ))

    If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Viewing 2 posts - 1 through 2 (of 2 total)

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