Improved date and date_time typecasting.