Anonymous Asked in Cars &Transportation · 2 weeks ago

How can get last 30 days data from a table in SQL Server?

Bookmark this question. Show activity on this post. SELECT * FROM product WHERE pdate >= DATEADD(day, -30, getdate()). 26 апр. 2017 г.


How do I get last 30 days from a table in SQL?

SELECT * FROM product WHERE pdate >= DATEADD(day, -30, getdate()).

How can I get last 3 months data in SQL?

In SQL Server, you can use the DATEADD() function to get last 3 months (or n months) records.

How do I get last 90 days data in SQL?

4 Answers1Actually you can do GETDATE()-90 instead DATEADD(DAY, -90, GETDATE()) – huMpty duMpty. Feb 20, 2014 at 16:45.2@huMptyduMpty But 3 months is not necessarily 90 days, because months may have 30 or 31 days (or even 28 or 29 if we take February into account) – AlexB. May 2, 2017 at 12:22.SQL query for getting data for last 3 months - Stack Overflow

How can I get last 7 days data in SQL?

Here's the SQL query to get records from last 7 days in MySQL. In the above query we select those records where order_date falls after a past interval of 7 days. We use system function now() to get the latest datetime value, and INTERVAL clause to calculate a date 7 days in the past.

Related Questions

Relevance
Write us your question, the answer will be received in 24 hours