Getting the Date function working properly