sqlite change date format of every cell in column

后端 未结 1 1406
遇见更好的自我
遇见更好的自我 2021-01-24 23:27

I have a table with a large number of rows. One column contains dates in the format \'%m/%d/%Y\' and I want to change all of them to format \'%Y-%m-%d\'

the usual: upd

1条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-24 23:45

    If the fields in the date string are properly padded with zeros, you can extract them as substrings:

    UPDATE MyTable
    SET MyDate = substr(MyDate, 7, 4) || '-' ||
                 substr(MyDate, 1, 2) || '-' ||
                 substr(MyDate, 4, 2)
    

    0 讨论(0)
提交回复
热议问题