How can get last 30 days data from a table in SQL Server?
- How do I get last 30 days from a table in SQL?
- How can I get last 3 months data in SQL?
- How do I get last 90 days data in SQL?
- How can I get last 7 days data in SQL?
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
-
Anonymous2 weeks ago
Expert answer2 weeks ago -
Anonymous2 weeks ago
Expert answer2 weeks ago -
Anonymous2 weeks ago
Expert answer2 weeks ago -
Anonymous2 weeks ago
Expert answer2 weeks ago -
Anonymous2 weeks ago
Expert answer2 weeks ago -
Anonymous2 weeks ago
Expert answer2 weeks ago -
Anonymous2 weeks ago
Expert answer2 weeks ago