Re: (Q) Subtract 6 months from a date: result=error -1267!!!
Posted in 1994
David I. Berg writes: ->... ->I won't take a stand, Cathy, one way or the other whether an error or an ->erroneous value should be returned in this circumstance. Consider, though, ->that to be mathematically correct if you subtract "5 UNITS 10" from the ->decimal number 65 and then add "5 UNITS 10" back to the answer, the result ->had better be your original value. The same principal applies here. If you ->were allowed to subtract "1 UNITS MONTH" from March 31 without an error ->and then added "1 UNITS MONTH" back to the answer you'd get March 28 (or ->29). I have a problem with this. -> ->... David, Your points are valid as are Alan Denney's. But how about solving the problem through use of an environment variable, say DB_MONTH_MATH. The default could then be the ANSI standard, or: DB_MONTH_MATH=ANSI - would behave as ANSI standard DB_MONTH_MATH=LAST - would assume that if the original day of month or the result day of month falls on the last day of the month (or greater), the result is the last day of the month DB_MONTH_MATH=n - where n indicates the number of days which should be assumed to be in a month. If n = 30, and 3 months are subtracted, then 90 days would be subtracted. If it wasn't too horrendous, n could be a decimal number, then you could set it to say 30.5 and round the result. You're right that mathematical properties should be maintained as should compliance with the ANSI standard, but it would be nice if there were an alternate solution. It just seems that there are always new people coming up against this problem, and while many people wish to remain ANSI compliant, there is always going to be a contingent of people who just want to get work done. Regards, - Cathy -------------------------------------------------------------------------------- Cathy Kipp ckipp@vth1.vth.colostate.edu Veterinary Teaching Hospital Phone: (303) 491-1294 Colorado State University Fax: (303) 491-1205 -------------------------------------------------------------------------------- Disclaimer:These are my opinions and may not represent anything at all relevant.