开发者

Converting strings to DATE in SQL Server

i have an old database that I'm converting from Access to MS SQL Server 2008. In the Access database, dates were written as 02/2008 so MM/YYYY. I want to convert this to a DATE type, where I can show something like MM/DD/YYYY. Is there any way to 开发者_如何学Godo that using SQL Server? When I tried CONVERT, it fails beacuse there are some irregular dates, such a

  • 1/2008
  • 01/2004
  • /2001
  • /4
  • etc

so my thought is that I will just write up some code to go through each date and use regex to convert it, and then save it back to the database in a new table.

Any thoughts on how to make this easier?


Looks like your only choice here is some sort of string manipulation like you've proposed. What part of the process would you like to make easier?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜