Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 516
gourav Avatar asked Apr 26 '11 10:04

gourav


2 Answers

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

Checkout date and time functions of mysql

like image 174
Shakti Singh Avatar answered Sep 30 '22 05:09

Shakti Singh


select '2011-04-26 05:00:00' - interval 12 * 60 + 30 minute
like image 34
Nicola Cossu Avatar answered Sep 30 '22 06:09

Nicola Cossu