Updating the Data to pull for 7 days

Ali, Feroze (FAli1) 26 Reputation points
2022-10-04T17:14:10.387+00:00

Below is the part of the code that is being changed. I want to modify the number of days in arrears that the bot is pulling the data, it was set for 14 days and we are updating it to pull for 7 days.

AND CONVERT(DATETIME, HSC.DateOfService) - CURRENT_TIMESTAMP < -6

AND CONVERT(DATETIME, HSC.DateOfService) - CURRENT_TIMESTAMP > -8

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,808 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,558 questions
{count} vote

Accepted answer
  1. CosmogHong-MSFT 23,321 Reputation points Microsoft Vendor
    2022-10-05T02:52:59.02+00:00

    Hi @Ali, Feroze (FAli1)
    If you want to get data from current datetime to last 7 days, then try something like this:

    WHERE  CONVERT(DATETIME, HSC.DateOfService) >= DATEADD(day,-7, CURRENT_TIMESTAMP)  
    

    Best regards,
    LiHong


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Ali, Feroze (FAli1) 26 Reputation points
    2022-10-07T11:58:30.647+00:00

    I just changed the Values to -6 and -8 and it solved the issue.

    0 comments No comments