By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
WITH yourTable AS (
SELECT '2021-01-23 12:34:43.123' AS Created, '2021-04-18 15:24:17.432' AS Expiry UNION ALL
SELECT '2021-02-19 10:01:01.231', '2021-02-19 00:00:00.000'
)
SELECT
Created,
Expiry,
CASE WHEN CONVERT(VARCHAR(10), Expiry, 102) = CONVERT(VARCHAR(10), Created, 102)
THEN 1 ELSE 0 END AS Same_Day
FROM yourTable;
Created | Expiry | Same_Day |
---|---|---|
2021-01-23 12:34:43.123 | 2021-04-18 15:24:17.432 | 0 |
2021-02-19 10:01:01.231 | 2021-02-19 00:00:00.000 | 1 |