Reputation: 807
Table: donate
Columns: donate_id, donate_active, donate_time
donate_time
value is a unix_timestamp
I have to select all entries 2 weeks before reaching the donate_time, to send a reminder email.
I tried many ways, but I always get a syntax error.
SELECT * FROM donate
WHERE donate_time >= UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 2 WEEK))
Upvotes: 1
Views: 1723
Reputation: 577
According to this page, INTERVAL
only supports WEEK
from version 5, and you said you are running 4.1. Try 14 DAY
instead of 2 WEEK
.
Upvotes: 2
Reputation: 159
I pasted your code and it works for me in MySQL Workbench 5.2.47.
Make sure you have a space after the table name and a semicolon at the end.
Check any surrounding code for sytax errors.
Here is the code I ran successfully. Try pasting back to your environment (change names).
SELECT * FROM requests
WHERE returntime >= UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 2 WEEK))
Upvotes: 1