How to convert below string to datetime in sqlserver '19-MAR-2018 12:00'
Asked
Active
Viewed 82 times
-2
-
1Select try_convert(datetime,'19-MAR-2018 12:00') – John Cappelletti Jul 29 '19 at 17:13
-
Possible duplicate of [SQL Server convert string to datetime](https://stackoverflow.com/questions/1135746/sql-server-convert-string-to-datetime) – Airn5475 Jul 29 '19 at 17:20
2 Answers
0
You can use CAST
to take string to a DATETIME
SELECT CAST('19-MAR-2018 12:00' AS DATETIME)

Airn5475
- 2,452
- 29
- 51
0
You can also use convert:
select convert(datetime, '19-MAR-2018 12:00', 100)

Krzysztof Atłasik
- 21,985
- 6
- 54
- 76

Y.K.
- 682
- 4
- 10