2014-02-25 4 views
2

나는 업무에서 분을 돌려 보내는 테이블이 있고 시간과 분으로 변환하고 싶으면. 선택의 나시간과 분에 mysql 분

은 다음과 같습니다 (60) 로 나누었을 때

select 
m.mat_nome as 'Matéria', 
round(
    sum(
     case when Hour(TIMEDIFF(est_horario_inicial, est_horario_final))*60 = 0 
      then Minute(TIMEDIFF(est_horario_inicial, est_horario_final)) 
      else Hour(TIMEDIFF(est_horario_inicial, est_horario_final))*60 
     end 
    )/60 
,2) 
as 'tempo' from estudos_realizados e 
left join materias m on e.mat_id = m.mat_id; 

은 그래서 이것은 내 테이블과 1.67 100 분을 반환 I는 시간과 분 1h40m 결과를 좀하고 싶습니다.

이것은 가능합니까? 어떻게 그 수를 60으로 나누고 소수 자릿수를 60으로 나눌 수 있습니까?

감사합니다.

답변

6

당신은 FLOOR() 함수와 간단한 수학을 보일 것입니다 당신은

CONCAT(FLOOR(minutes/60),'h ',MOD(minutes,60),'m') 
0

사용하여 다음과 같은 사실 : 시간 = 층/60 분 = (-hours * 60

0

뭔가를해야합니다. 이 문제가 해결되었습니다. 감사합니다.

select 
    m.mat_nome as 'Matéria', 
    CONCAT(
     FLOOR(
      sum(
       case when Hour(TIMEDIFF(est_horario_inicial, est_horario_final))*60 = 0 
        then Minute(TIMEDIFF(est_horario_inicial, est_horario_final)) 
        else Hour(TIMEDIFF(est_horario_inicial, est_horario_final))*60 
       end 
      )/60 
     ),'h', 
     MOD(
      sum(
       case when Hour(TIMEDIFF(est_horario_inicial, est_horario_final))*60 = 0 
        then Minute(TIMEDIFF(est_horario_inicial, est_horario_final)) 
        else Hour(TIMEDIFF(est_horario_inicial, est_horario_final))*60 
       end 
      ) 
     ,60) 
    , 'm') 
    as 'tempo' from estudos_realizados e 
left join materias m on e.mat_id = m.mat_id; 
관련 문제