I'm trying to get the "zeros" as the image shows
I have the following part of the query:
"sec_to_time(SUM(horas_semana)*3600) as horas_semana"
Which I do not know what else I can do to only show the "48" hours only.
Any advice?
You must define the output format. Something like this:
SELECT TIME_FORMAT(sec_to_time(SUM(horas_semana)*3600) as horas_semana,'%H') FROM table
Understanding "draw" how to remove (not show), then you want the result of the query to only show the number of hours without minutes and seconds.
As suggested in the responses of @federhico and @SoftMolina, you can use the function TIME_FORMAT
indicating the mask for hours %H
:
TIME_FORMAT(sec_to_time(SUM(horas_semana) * 3600), '%H') as horas_semana
To get only the time, minutes and seconds would be:
SELECT TIME(NOW())
although you could also use the DATE_FORMAT () function:
SELECT DATE_FORMAT(NOW( ), "%H:%I:%S" )
SELECT TIME_FORMAT(sec_to_time(SUM(horas_semana)*3600) as horas_semana,'%H') FROM table
Use the HOUR
Returns the time. The range of the return value is from
0
to23
for the values of time of day. However, the range of values ofTIME
is actually much higher, soHOUR
can return values greater than23
.
Example:
mysql> select HOUR(sec_to_time(SUM(horas_semana)*3600)) as horas_semana; +--------------+ | horas_semana | +--------------+ | 48 | +--------------+ 1 row in set (0.00 sec)