Definitions of date arithmetic

Markus Kuhn Markus.Kuhn at
Sun Oct 11 11:55:37 UTC 1998

Joe Celko wrote on 1998-10-10 22:59 UTC:
> > What is 1 month before 31 March?
> The ANSI X3H2 Database Standards committee looked at this and found that
> GAAP (Generally Accepted Accounting Practices) and other commercial users
> of date arithemetic all disagreed on how to handle months in expression. 
> For example, there are over 150 fiscal years, each with slightly different
> rules for this.  The Bond trade says a month is always 30 days, etc.  etc.
> Our solution in the SQL-92 standard was to only define math with interval
> units of one day or less.  Anything more than that was up to the user.


This entire discussion about month/year arithmetic is ridiculous,
because it is very obvious that the entire matter is extremely
application dependent. It is a "good thing" [TM] if application writers
are forced to do any month/year business arithmetic manually and they
must not be allowed to rely on any library semantics here. How exactly
week/month/year arithmetic should work is part of the application
specification and not the business of a clock API designer.

mktime() and equivalents should reject all out-of-range inputs and
should not try to do any semantically extremely dubious overflow
arithmetic. It is not good practice to abuse this poor function for
things it was never intended for.


Markus G. Kuhn, Security Group, Computer Lab, Cambridge University, UK
email: mkuhn at,  home page: <>

More information about the tz mailing list