0

I have a column in SQLite in the form 07/08/1963 and I need to change the age of all the persons in that column. Does anyone know the command to convert the entire column?

Column is title age

  • 1
    What do you mean by "*convert the entire column*"? Unless you set a `where` clause in your statement it will update all rows on that column. – Johan Oct 13 '18 at 17:04
  • Your question is quite vague but if I understand correctly, I think you probably want to do something like mysql's update YOURTABLENAME set age = datediff( now(), YOURDATECOLUMN)/365. – Nick M Oct 13 '18 at 18:04
  • Also see this answer https://stackoverflow.com/questions/38237563/sqlite-date-difference ...google is your best friend! you basically store a difference between two dates in a column. If that's what indeed what you want to do. – Nick M Oct 13 '18 at 18:05
  • Hey Nick M I think you are correct but I am working in SQLite.My current table 'person' has an age column in the form of 07/08/1988 but I don't know how to convert is to an actual age rather than a birth-date. – Rodrigo Hernandez Oct 13 '18 at 18:23
  • I don't think you can convert the type of a column (from `date` to `integer` (there's no such column as `age`)) and preserve or change the value at the same time. You would either need to export the data, do the convert and add the new data again. Or you would need to create a new column, set the values with a simple update, then remove the old column and possibly rename the new column to the old one. – Johan Oct 13 '18 at 21:52

0 Answers0