I have a data like below in table
and I want data like below
If there is any gap between the dates then it should check the next day whether the data available or not if available the end date should be the tdate of that row.
I tried to achieve this through analytic functions but no luck.


Something like this, perhaps?
Sample data:
Query begins here: