Remove duplicated code to get date for formula filtering