开发者

Sqlite: update DATE column, but change date only - preserve time

开发者 https://www.devze.com 2023-02-03 12:19 出处:网络
I need to update the actual date of a ton of rows, but preserve the time already in there.A script started incorrectly populating the rows incorrectly due to a programming error.I could proba开发者_高

I need to update the actual date of a ton of rows, but preserve the time already in there. A script started incorrectly populating the rows incorrectly due to a programming error. I could proba开发者_高级运维bly do this via an external script, but I figure there has to be a sqlite command to do this easily.

The column is described as this in the schema: logDate DATE NOT NULL,

A sample row looks like this: data8|dat7|200|2011--08 00:15|12

It SHOULD look like this: data8|dat7|200|2011-01-08 00:15|12

It's done this for the past 10 days. I can do individual updates for the past 10 days, or one big one, but I really am not sure where to start. I haven't found much via googling. If I do, I'll answer my own question.

Thanks in advance.


So I just did this:

UPDATE views SET logDate = REPLACE(logDate,'--','-01-') 
WHERE logDate LIKE '2011%';

Worked fine.

0

精彩评论

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