How to auto calculate the end date, if there's such function?