Reputation: 805
I have the table contains column create_datetime.It is timestamp(6) data type.
I used the below query to fetch the create_datetime-15 days records
The table having records for this condition But it is not listing for below query
SELECT create_datetime
FROM xy
WHERE create_datetime <= create_datetime-15
Upvotes: 0
Views: 41
Reputation: 559
You can try this:
SELECT create_datetime
FROM xy
WHERE create_datetime <= DATE_SUB(create_datetime, INTERVAL 15 DAY);
Let me know if this help you!
Upvotes: 1
Reputation: 424983
Specify the units of the subtraction:
create_datetime - NUMTODSINTERVAL(15, 'DAY')
Upvotes: 1