Re: Adding a month
Posted in 1998
On 22 Sep 1998, David C. Harrison wrote: > > I have a column datum (date type) in table. I would like to find a date > > one month later. So I would like my result to be: > > datum datum + 1 month > > 1998-1-17 1998-2-17 > > > > I have tried with extend, but no luck. > > SELECT (datum +1 UNITS MONTH) FROM table_name; This works until you try it on 31st March, 31st May, 31st August, 31st October, and 29th, 30th or 31st January in non-leap years (30th and 31st January in leap years). At that point, you have to decide what date is one month later and code something rather more carefully. Note that the last day of month solutions which worked best (Octavio's?) did not run into this problem; it calculated the first day of the current month, added one month, and then subtracted one day, which always works. Yours, Jonathan Leffler (jleffler@informix.com) #include <witticism.h> Guardian of DBD::Informix v0.60 -- http://www.perl.com/CPAN Informix IDN for D4GL & Linux -- http://www.informix.com/idn