0 votes
1 view
in SQL by (22.4k points)

I am writing a query in which I have to get the data for only the last year. What is the best way to do this?

SELECT ... FROM ... WHERE date > '8/27/2007 12:00:00 AM'

1 Answer

0 votes
by (40.3k points)

By using the below code, you can add -1 year to the current date:

SELECT ... From ... WHERE date > DATEADD(year,-1,GETDATE())

Related questions

0 votes
1 answer
0 votes
1 answer
asked Jul 22, 2019 in SQL by Tech4ever (22.4k points)
0 votes
1 answer
asked Jul 9, 2019 in SQL by Tech4ever (22.4k points)
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...