Re: Programming in 4gl (Dates)
Posted in 1993
In article <1pscquINN9ir@emory.mathcs.emory.edu> ckipp@vth1.vth.colostate.edu (Cathy Kipp) writes: >... Some interesting info though (which Informix doesn't take into account): >"If you generate a calendar for the year 1582, Oct. 4 will be immediately >followed by Oct. 15. This is not a bug; that year, the days Oct. 5 to Oct. 14 >were canceled when the Julian calendar was replaced by the more accurate (and >still used) Gregorian calendar. The functions in this article treat Oct. 4, >1582 and earlier dates as belonging to the Julian calendar, and Oct. 15, 1582 >and later dates as belonging to the Gregorian calendar." This is for the U.S.; Britain used a different date, and other countries varied quite a bit. Therefore, "correct" handling of the calendar switch is country-specific. How many more different versions of 4GL do you want? \\-: A good study of this appeared in "Computer Language" in 12/1990 and 3/91. >For my uses, I have a simple function with a case statement which calculates >the max day of the month given a month and a year (to account for leap year). >I do however consider it a BAD Informix feature that if you add a month to, >say March 31, that the correct reponse is an error (since April only has 30 >days). This "feature" has caused me to write my own routines for >adding/subtracting months to/from a date. This "feature" is an ANSI requirement; a good one, IMHO. (e.g. for SQL92, see the section on <datetime value expression> (6.14), General Rule 3b-c.) The alternative would not be logical for everybody; for example: a) what does "one month from January 31" mean? February 28th? February 29th in a leap year, and the 28th if not? March 1? March 2? b) what does "one month from January 30" mean? The same answer as in part (a)? If so, how can a month from today be the same day as one month from yesterday? (Consider: "It's just a jump to the left, and then a step to the right.") >| Cathy Kipp | Internet: ckipp@vth1.vth.colostate.edu | -- Alan Denney aland@informix.com {pyramid|uunet}!infmx!aland Disclaimer: Poster under influence of 1,3,7-trimethylxanthine "If your car has higher-quality fit-and-finish, you are more likely to believe that the wheels won't fall off at high speeds. For similar reasons, software salesmen tend to dress nicely." -- Curt Monash