lundi 4 janvier 2016

How to convert string date in BST and GMT format to SQL Server format as date type

I imported a table into SQL Server 2014 and I found that the date format is in BST and GST format. I want to create a view and change the whole column to SQL Server date type to perform operations. I don't mind truncating the time section.

Wed Apr 07 00:00:00 BST 1943
Tue Jan 08 00:00:00 GMT 1985

I was able to do it in Excel with the following formula but want to do it in SQL Server:

=IFERROR(DATEVALUE(MID(E2,9,2)&"-"&MID(E2,5,3)&"-"&RIGHT(E2,4)), "")

All I am looking for is

1983-08-04

Aucun commentaire:

Enregistrer un commentaire