Reputation: 3837
Is there a way to convert this NVARCHAR "datetime" ("28/08/2014 08:45:50") to a proper DATETIME datatype (2014-08-28 08:45:50)?
or perhaps even the other away around
2014-08-28 08:45:50 to "28/08/2014 08:45:50"
I've tried to CAST or CONVERT to DATETIME but I get this error
The conversion of a nvarchar data type to a datetime data type resulted in an out-of-range value.
Thanks in advance
Upvotes: 0
Views: 40
Reputation: 32713
This is because your date format is mdy. You can changed this by setting the DATEFORMAT
to dmy
. For example, try this:
SET DATEFORMAT dmy
SELECT CAST('28/08/2014 08:45:50' AS DATETIME)
Upvotes: 2