How do I subtract 9: 00 a.m. (09:00:00) from’ hours, minutes and seconds’ of a time field in the database to get the number of minutes

  mysql, question

My SQL is as follows:

select right(oph.create_time,8) – ’09:00:00′ from xxxxx,

Oph.create_time is a certain time in the database. For example, the data is 2016-07-07 19:24:30

However, the reduced data is hours, and those less than one hour are all recorded as 0. what I need is minutes. how do you operate it?


You can use this
(hour, oph.create _ time)-9) * 60 plus datepart (minute, oph.create _ time)
You can get minutes instead of the part in the red box above you.