I'm trying to convert a date in a varchar
column in the dd/mm/yyyy
format into the datetime dd/mm/yyyy
format, so then I can run date range queries on the data.
So far I have the following which is not working
CONVERT(varchar, CAST(date_started AS datetime), 103)
I have also tried
convert(date_started as datetime, 103)
I need to make sure the output is as dd/mm/yyyy
as we're in the UK and not the mm/dd/yyyy
format
I think you are after this:
CONVERT(datetime, date_as_string, 103)
Notice, that datetime
hasn't any format. You think about its presentation. To get the data of datetime
in an appropriate format you can use
CONVERT(varchar, date_as_datetime, 103)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With