Re: Month function in Informix?
Posted in 1999
Topics: Stored Procedures & SPL
Michael You could try : select to_char(mydate + interval(1) month to month, "%m/%d/%Y") from table; to display. If you just want to update, then update table set mydate = mydate + interval(1) month to month where condition; mydate can be a datetime or a date column. HTH Sujit Michael O'Sullivan <MichaelOS@peregrine.ie> on 11/23/99 09:40:07 AM Please respond to Michael O'Sullivan <MichaelOS@peregrine.ie> To: informix-list@iiug.org cc: (bcc: Sujit Pal) Subject: Month function in Informix? Hi folks, Is there a function in Informix similar to 'Add_Months()' in Oracle that simply adds to the month field in a date. Eg: Add_Months('15/07/1999', 1) = '15/08/1999' Thanks, Michael.
Sujit.Pal@bankofamerica.com wrote: > You could try > : > select to_char(mydate + interval(1) month to month, "%m/%d/%Y") from table; > Or SELECT TO_CHAR(mydate + 1 UNITS MONTH, "%m/%d/%Y") FROM Table; (I'm taking the TO_CHAR part on good faith). > > to display. If you just want to update, then > > update table > set mydate = mydate + interval(1) month to month > where condition; > > mydate can be a datetime or a date column. > > > > Michael O'Sullivan <MichaelOS@peregrine.ie> on 11/23/99 09:40:07 AM > Is there a function in Informix similar to 'Add_Months()' in Oracle that > simply adds to the month field in a date. > > Eg: Add_Months('15/07/1999', 1) = '15/08/1999' Beware, though. If the starting date is after the 28th of the month, adding an appropriate number of months to it will cause breakages. For example, adding 1 month to 31st of January would compute 31st February, but there is no 31st of February, and Informix does not try to decide whether you wanted the last day of February, or the 1st of March, or a date 30 days into the future, or a date 31 days into the future, or some other magical formula. It generates an error. Frankly, I think adding 1 month to arbitrary dates is downright dangerous. If you're adding the to a date in the body of the month, then there is always a plausible answer. But in the tail (29, 30, 31) -- no. -- Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net) Guardian of DBD::Informix v0.62 -- see http://www.perl.com/CPAN #include <disclaimer.h>