In the next query the column ' ROUPMJ ' I use it as a date to know when a product is available, but when I came in Juliana I converted it to smalldatetime
.
I need to take the difference of days to the current day in another column taking the field ' ROUPMJ ' as the starting date. This in order to know how many days pass after the product is available.
I attach the code:
With CT_Recibo AS
(
SELECT
CASE WHEN ROPOST = 5 THEN 'Liberado' END AS Estatus,
DateAdd (d,cast(ROUPMJ as int) - ((cast(ROUPMJ as int) / 1000) * 1000),
convert(smalldatetime,str((cast(ROUPMJ as int) / 1000) + 1900) + '0101')) - 1 AS Fecha,
ROTDAY 'Hora Liberacion',
ROEDOC 'Documento Ingreso',
ROVINV'Factura',
RODOCO 'No Orden',
RODCTO 'Tipo Documento',
ROLNID 'Linea',
ROSFXO 'No De Recibo',
ROLITM 'Codigo',
RODSC1'Descripcion Codigo',
ROUORG'Cantidad Solicitada',
ROUREC'Cantidad Recibida',
ROPOST
FROM f55m4324
WHERE ROPOST IN ('5')
AND ROEDOC NOT IN (SELECT ROEDOC FROM F55M4324 WHERE ROPOST IN ('7'))
) SELECT* FROM CT_Recibo