Get last 30 days records in MySQL
Question:
How to get last 30 days records in MySQL? Answer:
SELECT * FROM user_account
WHERE last_login_date > NOW() - INTERVAL 30 DAY;
Description:
The interval_expression represents a temporal interval. Intervals have this syntax:
INTERVAL expr unit
expr represents a quantity.
unit represents the unit for interpreting the quantity; it is a specifier such as HOUR, DAY, or WEEK.
The INTERVAL keyword and the unit specifier are not case sensitive.
Temporal arithmetic also can be performed in expressions using INTERVAL together with the + or - operator.
Reference:
Temporal intervals reference
Share "How to get last 30 days records in MySQL?"
Related snippets:
Tags:
get last 30 days records, now, interval, datetime Technical term:
Get last 30 days records in MySQL