Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using CONVERT() function
Message
From
07/02/2019 16:11:57
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Miscellaneous
Thread ID:
01666022
Message ID:
01666066
Views:
29
>My code does not use the XML serializer. And I cannot change the code - now - just for this case. So, I will have to find a solution still.
>Thank you.

Do you have access to the code that is doing the serialization? If yes, would you share so we can update.

If you have to live with that, there is a problem, consider:

01/02/2019

How would that be interpreted? It is Jan 2 in USA and Feb 1 in Europe. Assuming, in such case you would favor US settings (could be instead server default), I have created a demo code for you (SQL Server 2012 and later):

https://dbfiddle.uk/?rdbms=sqlserver_2017&fiddle=dda4d99a3924f79400ee650a0f822ae4

and this is shorter form of that:
update @sample
   set myDate = 
      Isnull( Try_Parse(dateStr as datetime using 'en-US'),
      Isnull( Try_Parse(dateStr as datetime using 'en-GB'),
       Try_Convert(dateTime, dateStr)));
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform