Looking for some help regarding mysql date functions.
I am looking to show data for a time period of today to 8 days ago (I have been using this line of code in mysql WHERE TIME > CURDATE() - INTERVAL 8 DAY
) ) as well as the above time period but one year ago.
答案 0 :(得分:0)
Try using DATE_SUB with TIMESTAMPDIFF,
TIMESTAMP
syntax,
TIMESTAMPDIFF(unit, datetime_expr1, datetime_expr2);
DATE_SUB
syntax,
DATE_SUB(date, INTERVAL value unit);
Example,
SELECT TIMESTAMPDIFF(SECOND, DATE_SUB('2018-06-04 22:59:00', INTERVAL 10 DAY),
'2018-06-04 22:59:00');