Keith Roberts <ke...@karsites.net> wrote:
> From: http://www.sqlite.org/lang_datefunc.html
> 
> "Thus, for example, the data 2001-03-31 modified by '+1
> month' initially yields 2001-04-31, but April only has 30
> days so the date is normalized to 2001-05-01."
> 
> When I add '+1 month' to the example data, the example date
> has 31 days added to it. Which is correct.
> 
> When I subtract '-1 month' the date only gets 28 days
> subtracted from it.

By the same logic, subtracting one month from 2001-03-31 leads to 2001-02-31, 
but Feburary only has 28 days, so this gets normalized to 2001-03-03. It's not 
about the number of days. If you want to add or subtract a particular number of 
days, say so.

> Surely adding or subtracting a month modifier to a date
> should be the same number of days in each direction?

If that were the case, then these two equalities could not be both true:

date('2001-03-01', '-1 month') = '2001-02-01'
date('2001-03-01', '+1 month') = '2001-04-01'

Which one of the above do you believe is incorrect?

Igor Tandetnik


_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to