build_date_fn helper function