mal at egenix.com
Mon Jan 19 13:01:28 CET 2004
Francois Girault wrote:
> On Thu, 15 Jan 2004 11:50:55 +0100
> M.-A. Lemburg wrote:
>>Francois Girault wrote:
>>>So the behavior we expect is the same than postgresql with interval
>>>type. IMHO, postgresql (ie SQL99 interval type) has a very logical
>>>point of view about this non obvious problem. What do you think
>>>about that ?
>>Do you have a reference for this ?
> This directory contains many docs about SQL99 :
> But I haven't found a fully explained date arithmetic.
> In this document :
> a chapter about interval says on page 29 : "Arithmetic
> operations involving values of type datetime or interval obey the
> natural rules associated with dates and times and yield valid datetime
> or interval results according to the Gregorian calendar."
> "natural rules" are *very* ambigious, but playing with postgres tell
> more about that :
> => SELECT date('2002-01-30') + "interval"('1 mon');
> 2002-02-28 00:00:00
> (1 row)
> For date from january, 28th to january, 31th adding one month result in
> the last day of february. From a math point of view, it seems wrong, but
> thinking more about make me consider it 'natural'
The problem with this approach is obvious, e.g. what would
the outcome of the following variations be:
Date(2004,1,31) + RelativeDateTime(months=+1)
Date(2004,1,31) + RelativeDateTime(months=+2) - RelativeDateTime(months=-2)
Date(2004,1,31) + RelativeDateTime(months=+3)
BTW, the stragety chosen in mxDateTime's implementation for
RelativeDateTime matches that of MS Excel VBA, see e.g.
(Only by accident, I must say :-)
Professional Python Services directly from the Source (#1, Jan 18 2004)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::
More information about the egenix-users