MySQL has a function called STR_TO_DATE, that converts a string to date.
Is there a similar function in SQL Server?
If you need to parse a particular format, use CONVERT(datetime, @mystring, @format)
. Use this as a reference: http://www.sqlusa.com/bestpractices/datetimeconversion/
What if the string is 7/7/2010?
Then use CONVERT with either 101 (mm/dd/yy) or 103 (dd/mm/yy) depending on what you want:
SELECT CONVERT(DATE, '7/7/2010', 103)
Result:
2010-07-07
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