Jon Dixon <[EMAIL PROTECTED]> wrote: > I am updating how I handle dates/durations in a database of mine and > I would like to come up with an SQL command to make the change for > me. > > The old format had a field Departure (YYYY-MM-DD) and a field Nights > (an integer), where the new format > still uses Departure but adds Return (YYYY-MM-DD) and the duration is > calculated from the difference between Departure and Return. > > My stab at an SQL statement to pull this change off is as follows: > UPDATE > Events SET Return = date(d, n + ' days') WHERE pkIndex IN (SELECT > pkIndex, Nights AS n, Departure AS d FROM Events WHERE Return = '' AND > Nights != '') > > (trying to get the field Return to be "Nights" > days after Departure, so long as Return wasn't set already and Nights > is set, in case my aim is not clear from the attempted SQL)
Perhaps something like this: update Events set Return = date(Departure, Nights || ' days') where Return is null and Nights is not null; Igor Tandetnik _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users