Anonymous Asked in Cars &Transportation · 2 weeks ago

How do 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 30 days records in SQL?

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

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 do I get last 6 months data in SQL?

Instead of approximating the "current" date by selecting the MAX(date) the code could reference CAST(GETDATE() as DATE) to access the system datetime and cast it as type DATE. where [date] > dateadd(month, -6, cast(getdate() as date));

How do I add 3 months to a date in SQL?

SQL Server DATEADD() Function The DATEADD() function adds a time/date interval to a date and then returns the date.

Related Questions

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