1

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?

Jack Casas
  • 914
  • 18
  • 37
  • https://stackoverflow.com/questions/9680144/mysql-date-time-round-to-nearest-hour will probably steer you in the right direction. – ceejayoz Feb 05 '18 at 16:15
  • Possible duplicate of [MYSQL Date Time Round To Nearest Hour](https://stackoverflow.com/questions/9680144/mysql-date-time-round-to-nearest-hour) – PM 77-1 Feb 05 '18 at 16:16
  • close, but I don't have date as the other post. I only have a time field – Jack Casas Feb 05 '18 at 16:24

1 Answers1

1

If you want only the hour you could use

TIME_FORMAT(MyTimeField,'%H:00:00')
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107