• Could you please recheck the CASE statement...I think it should be..

    -- [Jourprod] AS

    CASE WHEN heure_passage BETWEEN '00:00:00' and '05:59:59' THEN day(jour_passage) -2

    ELSE day([date_passage]) -1

    END AS [Jourprod]