Create an table that is sorted by Id and Date desc. If there is a change in Id or Date differs from the previous record more than 1 day, that's indicating a not continued Id, hence set the Exit flag to 1.

The where clause removes the very last date (i,e, for the very last date in our records, we don't know if Id is really discontinued or maybe it will appear again tomorrow with the next record). Adapt if this clause is not needed.

Then the date will be modified to the next working day using LastWorkDate() function and set as CountDate. Why to the next date? Because we are not interested at the last date where Id exists, but in the following working day where it doesn't exist for the first time.