Sharpeye
Sharpeye

Reputation: 13

Date difference in mysql

In a mysql table for a date column(login_time), i need to get the logins for

last 30 days, last 60 days.

Is there any way to do that?

Thanks.

Upvotes: 1

Views: 152

Answers (1)

Piskvor left the building
Piskvor left the building

Reputation: 92792

this will give you the rows from the table where login_time is within the last 60 days:

SELECT * FROM table WHERE login_time >= SUBDATE(CURDATE(),INTERVAL 60 DAY)

similarly with 30 days.

Upvotes: 4

Related Questions