Concatenation of a Select field in the ADDTIME

1
"SELECT     at.codigoTurma, "
           "ADDTIME(t.horaInicioCurso, '00:01:00'), "
           "t.toleranciaCurso, "
           "t.horaFinalCurso "
"FROM       AlunosTurmas at "
"INNER JOIN Turmas t "
"ON         t.codigoTurma = at.codigoTurma "
"WHERE      at.matriculaAluno = :matricula "
"ORDER BY   t.horaInicioCurso"

I would like to use the t.toleranciaCurso field, in the ADDTIME function, instead of the minutes.

t.tolerancia(INT), t.horaInicioCurso(TIME).
ADDTIME(t.horaInicioCurso, '00:' + t.toleranciaCurso + ':00') // soma apenas segundos
    
asked by anonymous 27.07.2015 / 19:10

1 answer

1

Since the second parameter of the ADDTIME() function must be of type TIME and you want to use a column dot type INT you need to convert with the function SEC_TO_TIME() :

SEC_TO_TIME(t.toleranciaCurso * 60)

This function waits the number of seconds, as you have minutes, you need to convert to this unit of measure in simple arithmetic.

    
27.07.2015 / 19:25