fixed complex_date sql