Forum Discussion
Sajj_Mak
Aug 07, 2023Copper Contributor
unable to change nvarchar to datetime type
I am unable to change the nvarchar type to datetime type 2023-08-03T02:00:31+00:00 please help
2 Replies
Sort By
- olafhelperBronze Contributor
Sajj_Mak use only the valid left part together with CONVERT and the date sytle 126 = ISO,
DECLARE @date nvarchar(50) = N'2023-08-03T02:00:31+00:00' SELECT CONVERT(datetime, LEFT(@date, 19), 126)
See CAST and CONVERT (Transact-SQL) - SQL Server | Microsoft Learn
- Sajj_MakCopper ContributorThanks!