'mysql time format to get only hours and minutes
I am struggling with the syntax for a MYSQL query.
I am currently just grabbing all fields via select * from TABLENAME
.
It works but the fields that are type=time
come back with this format:
01:14:00.000000
Is there a way for format the query to just get a 24hr time (only hours and minutes)?
Solution 1:[1]
Did you look at time_format?
SELECT TIME_FORMAT(`TABLENAME.TIME`, '%H %i'), `OTHERFIELDS` FROM TABLENAME;
Code is untested, but should work.
Solution 2:[2]
select TIME_FORMAT(`TABLENAME.TIME`, '%H:%i') as column_name FROM TABLENAME;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | dmikester1 |
Solution 2 | Suraj Rao |