Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have a column of data type varchar in my table, I would like to create another column of data type DATE and dump those data into newly created date column.

I am trying to use

UPDATE Table
Set NewColumn= Convert(Date,StringDateColumn,103)
It is giving same result yyyy-mm-dd for 104,105 style also. But for other styles it is giving error "Conversion failed when converting date and/or time from character string

The above query is giving yyyy-mm-dd format

1. The format in StringDateColumn is dd/mm/yyyy
2. I would like to get same format dd/mm/yyyy

Any ideas...

Thanks.
Posted

1 solution

Give this a try:
SQL
UPDATE Table
Set NewColumn= CONVERT(Date, StringDateColumn)CONVERT(VARCHAR(10), GETDATE(), 103)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900