简体   繁体   中英

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.

The output should be 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() .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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