tmartin314 tmartin314 - 6 months ago 9
SQL Question

My SQL grab last active users within one week

I have a query and I'm not sure how to limit the users by last login date. i only want to return the users who have logged in in the last week. Here's my query:

"SELECT `ID` FROM `Profiles` WHERE `DateLastLogin` < '[1WEEK]'"


The DateLastLogin is a datetime field.

Answer
WHERE DateLastLogin > ADDDATE(NOW(), INTERVAL -1 WEEK)