Operation of datiff in SQL 2014

Asked

Viewed 23 times

-1

I have an accumulated base of dates in sql, I wanted to select all dates you have from the current date (today) until 60 days ago, but I’m not getting the code right.

***select
    data
    CPF,
    sum(risco) as risco
    from BASE_ACUMULADA
    where  Data in (datediff(dd, 0, getdate())),(datediff(dd, 0, getdate())-60))
    group by data, CPF***

1 answer

-1

Try this suggestion using the operator Between:

where Data between dateadd(dd, -60, cast(getdate() as date)) and getdate()

I hope it helps

Browser other questions tagged

You are not signed in. Login or sign up in order to post.