0

I have a column named as recordTime in my Access DB table table1.

This column is of TEXT type right now, and most of its value are in format as: yyyy-mm-dd hh:nn:ss, but there are also some wrong records like this: yyyy-mm- ::.

Now I would like to change the data type of this column from TEXT to DATETIME. I tried with the following query but nothing happens:

             ALTER TABLE table1
             ALTER COLUMN recordTime DATETIME;

Am I doing it wrong?

4

1 回答 1

2

尝试运行这些:

ALTER TABLE table1 ADD NewDate DATE

然后运行

UPDATE table1
SET NewDate = RecordTime
WHERE RIGHT(RecordTime,4) <> '- ::'

然后您可以删除RecordTime并重命名NewDate.

我更喜欢添加一个新列,以防万一有任何问题,UPDATE您可以在继续之前比较“清理”列和初始数据。

于 2013-09-13T07:17:43.973 回答