Convert DD-Mon-YYYY to DD/MM/YYYY

2019-06-20 04:29发布

问题:

I need to convert dt_of_birth [varchar] (15) which is in the format DD-Mon-YYYY to DD/MM/YYYY.

dt_of _birth is specified in different table and the conversion had to be done and stored in another table which has the same column name as dt_of_birth.

回答1:

Here

SELECT convert(datetime, '23/10/2016', 103) -- dd/mm/yyyy


回答2:

This will work

SELECT CONVERT(CHAR(11), CONVERT(SMALLDATETIME, '27-Jan-2011', 13), 103);


回答3:

Try this:-

 SELECT CONVERT(CHAR(11), CONVERT(SMALLDATETIME, '23-Oct-2016', 13), 103);

103 is for dd/mm/yyyy format

Check out this link



回答4:

Try this:-

INSERT INTO SecondTable(Column1)

SELECT CONVERT(VARCHAR(10),CAST(dt_of_birth AS DATETIME),103) FROM FirstTable