Below script converts string(varchar) to date. Date value in string can be in the format mm/dd/yy (or) mm-dd-yyyy
[sql]
–mm/dd/yyyy
SELECT CAST(’12/30/2000′ AS DATE)
–mm-dd-yyyy using cast
SELECT CAST(’12-30-2000′ AS DATE)

–mm/dd/yyyy using cast
SELECT CONVERT(date,’12/30/2000′)
–mm-dd-yyyy using cast
SELECT CONVERT(date,’12-30-2000′)
[/sql]

Leave a Reply

Your email address will not be published. Required fields are marked *