-1

I have two fields in my table : last_service_date and the next_service_date. The last_service_date has a default timestamp. What I want is to add 3 months to the next_service_date. Is that possible?

Irfan Sindhi
  • 75
  • 1
  • 8

2 Answers2

1

You can use SQLite Date and Time Functions

Example of usage:

UPDATE tablename SET next_service_date=DATETIME(last_service_date , '+3 months');
canillas
  • 414
  • 3
  • 13
0

You can just run a simple sql command

UPDATE tablename SET next_service_date = last_service_date + (60*60*24*30*3);

That would do the job, but keep in mind that this piece of code changes every entry in the table! You may want to add a LIMIT to that.

Also, I assumed you wanted to add 3 months to the last_service_date. You may need to change that accordingly.

Some months may also have more or less than 30 days, which I used as a base.

abcdefg
  • 33
  • 1
  • 4