Add minutes in an SQL query

0

I have a "Programming" table with the following data (NOT MODIFIED):

HoraInicio = 08:15 (Char 5),
HoraFin = 12:15 (Char 5),
TiempoPromedioAtencion = 15 (INT),
IdProgramacion = 79647 (INT)

I would like to know if there is any way to make a query in which add the field HoraInicio "08:15" + TiempoPromedioAtencion "15" como un bucle que finalice en HoraFin "12:15" and obtain the result in a single column, separated by rows obviously, like the following:

HorasDisponible   
08:15 - 08:30  
08:30 - 08:45  
08:45 - 09:00  
...  

12:00 - 12:15

or in separate columns like:

HorasDisponible1 = 08:15,
HorasDisponible2 = 08:30
...
HorasDisponible1 = 12:00,
HorasDisponible2 = 12:15

At the moment I have managed to correctly add HoraInicio "08:15" + TiempoPromedioAtencion "15" with this SQL query code:

Select DATEADD(s,TiempoPromedioAtencion*60,0)+CONVERT(datetime, HoraInicio,120) 
as HorasDisponbile  from ProgramacionMedica
where  IdProgramacion= '79647'

Throwing the following result in a single column:

HorasDisponible   
1900-01-01 08:30:00.000

Can this query be improved in order to provide the results I want? Or use another type of query that you can give me. Thank you very much for your help in advance.

    
asked by jefflr 05.06.2018 в 19:49
source

0 answers