简体   繁体   English

如何从MySQL日期字段中减去12小时30分钟

[英]how to subtract 12 hours 30 minutes from the MySQL from date field

I have reduce or subtract 12 hours 30 minutes from the 2011-04-26 05:00:00(in the format YYYY-MM-DD HH:MM:SS) IN MySQL database. 我在2011-04-26 05:00:00(格式为YYYY-MM-DD HH:MM:SS)的MySQL数据库中减少或减去12小时30分钟。

The output should be 2011-04-25 16:30:00. 输出应该是2011-04-25 16:30:00。

Are there any date function we can use and subtract? 我们可以使用和减去任何日期函数吗?

DATE_SUB(`date`,INTERVAL '12:30' HOUR_MINUTE)

结帐mysql的日期和时间函数

The date/time functions are documented here: 日期/时间功能在此处记录:

You probably want DATE_SUB() . 你可能想要DATE_SUB()

select '2011-04-26 05:00:00' - interval 12 * 60 + 30 minute

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM