Re: datetime - datetime = interval but it is always null
Posted in 1997
Marco Greco wrote: > > Yes. If you don't use a multiple of 12 as the number of months (60 obviously > is a multiple), you are likely to hit err 1267 (the result of a datetime > computation isout of range) where s_date approaches the end of the month. > Better use days or years instead. > > HTH, > Marco > > Ah. After a month, I forgot what the original post was about (OK, OK, I > probably deleted it without even reading it first :-), so I just don't know > what the original poster was asking. > ____________________________________________________________________________ > rem radioterapia, which I immeritately manage, seldom agrees with what I say > > marco greco (Catania, Italy) Work: > marcog@ctonline.it rem radioterapia 39 95 447828 fax 446558 > (was mar.greco@agora.stm.it) Achea 39 95 503117 > > --- On Mon, 13 Jan 97 08:10:35 GMT Rudy Fernandes <rferdy@kuwait.net> wrote: > > Here's a different approach. (The following code works on 4.1) > > IF s_date + 60 UNITS MONTH > e_date THEN > discard... > ELSE > place in bin... > END IF > > Or have I missed something in the problem? > > >}From: Kirk Waterhouse <kirk.waterhouse@usat.mhs.ciba.com> > >}Date: Wed, 18 Dec 1996 16:32:59 -0800 > >}X-Informix-List-Id: <news.31813> > >} > >}I am trying to compare the expiration date of a unit of inventory with > >}the location I would like to put it in. If there is more than 60 months > >}difference I want to put it somewhere else. > > ---------------------- > Rudy Fernandes > GIC, Kuwait > ---------------------- > > -----------------End of Original Message----------------- I'm not sure what you're asking, but a recent e-mail where I work enlightened me to the fact that you should always provide units when doing date-time calculations. I'm not sure if it defaults to a certain units or not. I do know that the date format is the number of days since 1970 and you can subtract an amount of days from that, however, the datetime is a completely different animal (so I'm told). Apparently, Informix assumed the correct units on one platform, but the code failed on another. The fix was to supply the units, which if I recall correctly (I don't really remember) were supplied as days. Whether or not the code should have worked on the other platform should be irrelevant; to write the best possible code is to leave as little to chance (even if it would be a compiler or database engine problem) as possible (e.g. Cursors (except hold cursors) are closed automatically upon the end of a transaction (commit or rollback); don't trust that functionality...there is a platform and version of Informix, which won't do that (can't remember exactly which, but it happened....and even if it didn't, you may run into another platform/version specific problem which you could narrow down by assuring yourself you did everything else explicitly, rather than trusting implicit behaviour defined in documentation.) Hope this helps, - Daniel Wright danwright@bigfoot.com