SELECT agenda.idagenda,agenda.idcontenido,agenda.idtema,agenda.tipocontenido,agenda.llave,agenda.accesibilidad,agenda.titulo,agenda.horainicio,agenda.horafin,agenda.publicar,agenda.opciones,agenda.orden,datediff(minute,horainicio,getdate()) as dif1,datediff(minute,getdate(),horafin) as dif2 FROM agenda WHERE agenda.idtema=171 ORDER BY agenda.orden