this is my query.
SELECT atdate,format(atdate,'ddd') as att_date,LvType FROM leavtran
WHERE AtDate between ('2019-02-01') and ('2019-02-28')
I want an add Sunday in the DateTime column.
this is my query.
SELECT atdate,format(atdate,'ddd') as att_date,LvType FROM leavtran
WHERE AtDate between ('2019-02-01') and ('2019-02-28')
I want an add Sunday in the DateTime column.
You want all days in February. Basically, this suggests a LEFT JOIN
. You don't mention the database, but the idea is something like this:
SELECT dt.atdate, FORMAT(dt.atdate, 'ddd') as att_date, lt.LvType
FROM (SELECT '2019-02-01' as dte UNION ALL
SELECT '2019-02-02' as dte UNION ALL
. . .
SELECT '2019-02-28' as dte
) d LEFT JOIN
leavtran lt
ON lt.AtDate = d.dte ;
In your particular case, you could also just use UNION ALL
with the Sunday dates:
SELECT lt.atdate, format(lt.atdate,'ddd') as att_date, lt.LvType
FROM leavtran
WHERE lt.AtDate BETWEEN '2019-02-01' AND '2019-02-28'
UNION ALL
SELECT '2019-02-03', 'Sun', NULL
UNION ALL
SELECT '2019-02-10', 'Sun', NULL
UNION ALL
SELECT '2019-02-17', 'Sun', NULL
UNION ALL
SELECT '2019-02-24', 'Sun', NULL
ORDER BY atdate;