works for date and datetime