clear markdown compare help best fiddles feedback dbanow.uk
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 2805490 fiddles created (40772 in the last week).

CREATE TABLE TableDataRange( ObjectId INTEGER NOT NULL PRIMARY KEY ,Amount INTEGER NOT NULL ,beginDate DATE NOT NULL ,endDate DATE ); INSERT INTO TableDataRange(ObjectId,Amount,beginDate,endDate) VALUES (1,500,'2020-12-28',NULL); INSERT INTO TableDataRange(ObjectId,Amount,beginDate,endDate) VALUES (2,35,'2019-09-26','2019-10-01'); INSERT INTO TableDataRange(ObjectId,Amount,beginDate,endDate) VALUES (3,200,'2020-05-28','2020-06-02');
3 rows affected
 hidden batch(es)


select * from tabledatarange;
ObjectId Amount beginDate endDate
1 500 2020-12-28
2 35 2019-09-26 2019-10-01
3 200 2020-05-28 2020-06-02
 hidden batch(es)


select t.objectid, t.amount, dateadd(day, x.n, t.begindate) as dt from ( select row_number() over (order by (select null)) - 1 from (values(0),(0),(0),(0),(0),(0),(0),(0),(0),(0)) a(n) cross join (values(0),(0),(0),(0),(0),(0),(0),(0),(0),(0)) b(n) cross join (values(0),(0),(0),(0),(0),(0),(0),(0),(0),(0)) c(n) ) x(n) inner join tabledatarange t on dateadd(day, x.n, t.begindate) <= case when enddate <= convert(date, getdate()) then enddate else convert(date, getdate()) end order by objectid, dt
objectid amount dt
1 500 2020-12-28
1 500 2020-12-29
1 500 2020-12-30
1 500 2020-12-31
2 35 2019-09-26
2 35 2019-09-27
2 35 2019-09-28
2 35 2019-09-29
2 35 2019-09-30
2 35 2019-10-01
3 200 2020-05-28
3 200 2020-05-29
3 200 2020-05-30
3 200 2020-05-31
3 200 2020-06-01
3 200 2020-06-02
 hidden batch(es)