Search code examples
sqlsql-serverssms

SQL Weekly Data Update


We have a database which is updated every Sunday the dataset looks like below;

[AccountID] [AccountName] [AccountContact] [Package] [NextTransactionDate] [ReportDate]

I use this data to create a power BI query which is automated to run every Monday as the data is updated every Sunday afternoon

I only want to use the data that has come in on the latest Sunday and not the data from the previous weeks. i.e. [ReportDate] The BI report only needs to show the data from let's say 25/10/20 and then on the next cycle 01/11/20 and so on. But this has to be automated using a query so it doesn't need to manually update every week


Solution

  • you can add a where statement base on current db time in your query

    WHERE ReportDate >= DATEADD(day,-7, GETDATE())
    

    this should work just fine.