Optimized and corrected getDate method for archiving.