I have a query:
SELECT * FROM msc_calendar WHERE calendar_userId = 1 AND end < UNIX_TIMESTAMP()
Is there a way to subtract a week from the timestamp, i.e. to see if end
was more than a week ago?
@EugenRieck's solution will break on edge cases like weeks where there's a daylight savings switch. It's better to use the built-in function for this, DATE_SUB
:
SELECT * FROM msc_calendar WHERE calendar_userId = 1 AND 'end' < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 WEEK))
SELECT * FROM msc_calendar WHERE calendar_userId = 1 AND 'end' < UNIX_TIMESTAMP()-7*24*60*60
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With