Está en la página 1de 2

Tiempo en Nave

---------------If(cod_accion='D',
if( Isnull(fc_desconexin),0,
if( Isnull(fc_transferencia),getdate()-fc_desconexin,
fc_transferencia - fc_desconexion),
If( Isnull(fc_transferencia),0,
if( Isnull(fc_conexion), getdate() - fc_transferencia,
fc_conexion -fc_transferencia
)
Tiempo en Patio
---------------If(cod_accion='D',
if( Isnull(fc_transferencia),0,
if( Isnull(fc_conexion),getdate()-fc_transferencia,
fc_conexion - fc_transferencia),
If( Isnull(fc_desconexion),0,
if( Isnull(fc_transferencia), getdate() - fc_desconexion,
fc_transferencia - fc_desconexion
)
SELECT tiempo_en_patio = CASE WHEN cod_accion = 'D' THEN
CASE WHEN fc_transferencia IS NULL THEN 0
ELSE
CASE WHEN fc_conexion IS NULL THEN DATEDIFF(mi,fc_transferencia, GE
TDATE()) ELSE DATEDIFF(mi,fc_transferencia,fc_conexion) END
END
ELSE
CASE WHEN fc_desconexion IS NULL THEN 0
ELSE
CASE WHEN fc_transferencia IS NULL THEN DATEDIFF(mi,fc_desconexion,
GETDATE()) ELSE DATEDIFF(mi,fc_desconexion,fc_transferencia) END
END
END
FROM uts_tort_wpr_reefers
SELECT tiempo_en_nave = CASE WHEN cod_accion = 'D' THEN
CASE WHEN fc_desconexion IS NULL THEN 0
ELSE
CASE WHEN fc_transferencia IS NULL THEN DATEDIFF(mi,fc_desconexion,
GETDATE()) ELSE DATEDIFF(mi,fc_desconexion,fc_transferencia) END
END
ELSE
CASE WHEN fc_transferencia IS NULL THEN 0
ELSE
CASE WHEN fc_conexion IS NULL THEN DATEDIFF(mi,fc_transferencia,GET
DATE()) ELSE DATEDIFF(mi,fc_transferencia,fc_conexion) END
END
END

FROM uts_tort_wpr_reefers