This is a tip for SQL server – if you have a database where dates are stored as text and want to convert them all to date values.

1. Create a new column for the date value – columnName_asDate

2. Run the following script


UPDATE table_name
SET columnName_asDate = CONVERT(DATETIME, RIGHT(columnName, 4) + SUBSTRING(columnName, 3, 2) + LEFT(columnName, 2), 112)


No Comments on “Tip: Convert dates stored as text into date values”

You can track this conversation through its atom feed.

No one has commented on this entry yet.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>