Search code examples
mysqltime-format

MySQL. How to get o'clock time from hour


I have a time datatype field "MyTimeField" in MySQL. So for example the value can be 10:30:00

I want to select the "o'clock time" in time format, so the output will 10:00:00

tried

 TIME_FORMAT(hour(MyTimeField),'%T')

but no luck, this returns 00:00:10

Any ideas?


Solution

  • If you want only the hour you could use

    TIME_FORMAT(MyTimeField,'%H:00:00')