db字段值+1小时

时间:2015-11-19 10:40:05

标签: php mysql sql datetime timestamp

SELECT * FROM (`tabl1` as ap)
WHERE (ap.fromdate BETWEEN "2015-11-20 11:00:00" AND "2015-11-20 12:00:00")
 AND (date('Y-m-d H:i:s',strtotime(ap.fromdate)+3600)
      BETWEEN "2015-11-20 11:00:00" AND "2015-11-20 12:00:00")

1 个答案:

答案 0 :(得分:1)

使用DATE_ADDINTERVAL

DATE_ADD(NOW(), INTERVAL 1 HOUR)

NOW() + INTERVAL 1 HOUR

如果您的日期时间名称为ap.fromdate,请使用此选项: -

ap.fromdate + INTERVAL 1 HOUR