I have done something similar, but this does seems quite messy. Is there not another solution.

The question still stands. At what stage is the date being changed?