Created function for calcDate