Re: (Q) Subtract 6 months from a date: result=error -1267!!!
Posted in 1994
>>> date. This column needs to specify dates including the day in month. >>> However, we wish to do a select on this column producing the last 6 >>> months rows to a specific day. Hence our select looks like: >>> >>> This should produce all rows within 6 months to the day. >>> ^^^^^^^^^^ >>> >>> What we want is the following results: >>> >>> (current date) (current-6 months) >>> 1994-03-15 1993-09-15 >>> 1994-03-31 1993-09-30 >>> >>> How can we achieve what we want with informix? 4gl function: function backmon(orig, num) ---------------------------------------------------------------------- define orig date define num smallint define newdate date define mon datetime year to month let mon = extend(orig, year to month) - num units month let newdate = mon + 1 units month let newdate = newdate - 1 units day if day(orig) < day(newdate) then let newdate = mon let newdate = newdate + (day(orig)-1) units day end if return newdate end function # backmon