Moving date command outside of loop