Translating with DrWatson… this can take a few seconds the first time.
This is a genuine, complex translation. DrWatson protects commands, error codes, and log output while naturally translating the surrounding text. It’s translated once and saved.
Terrence Mullins found DATETIME(2004-12-31) YEAR TO DAY + 4 UNITS MONTH fails with error 1267 while Dec 30 works. June C. Hunt referred to earlier comp.databases.informix threads. Kevin Doiron said April 31 is invalid. Paul Watson asked what four months from the 31st should mean and gave the month-end workaround: add 5 UNITS MONTH to the first of the month and subtract 1 UNITS DAY.
Auto-generated by Claude from the posts below — may be imperfect; read the full thread.
All,
I'm trying to get a date value that is 4 months from a given day. If I use:
select datetime(2004-12-30) year to day + 4 units month from dummy
I get 2005-04-30
However, if I try:
select datetime(2004-12-31) year to day + 4 units month from dummy
I get an error:
1267: The result of a datetime computation is out of range.
I tried using + 120 day - but this doesn't always give you exactly 4 months.
Am I out of luck here????
-Terrence
↪ replying to Terrence Mullins
June C. Hunt — — source: IIUG Forums & Mailing Lists
"Terrence
Mu...." wrote:
>
>All,
>
>I'm trying to get a date value that is 4 months from a given day. If I
>use:
>
>select datetime(2004-12-30) year to day + 4 units month from dummy
>
>I get 2005-04-30
>
>However, if I try:
>
>select datetime(2004-12-31) year to day + 4 units month from dummy
>
>I get an error:
>1267: The result of a datetime computation is out of range.>
>
>I tried using + 120 day - but this doesn't always give you exactly 4
>months.
>
>Am I out of luck here????
>
Out of luck? No. This subject has come up many, many times. For a couple
of very good threads that cover this, go to Google and search
comp.databases.informix for the subject: Date calculation functions :
Informix bug? or the subject: Last Date of previous month. Actually, if you
just search comp.databases.informix with *all* the words 'datetime' and
'month', you'll find some very good descriptions of why 'UNITS MONTH' isn't
giving you what you want, and you will find some helpful suggestions to work
around your problem. Take a look at the two suggested threads first - there
is a lot of information out there. These two should get you headed in the
right direction.
--
June Hunt
_________________________________________________________________
Tax headache? MSN Money provides relief with tax tips, tools, IRS forms and
more! http://moneycentral.msn.com/tax/workshop/welcome.asp
↪ replying to Terrence Mullins
KEVIN DOIRON — — source: IIUG Forums & Mailing Lists
You're getting the error because 04-31 is an invalid date.
(I'm sure you figured that out). If you're always going forward from the end
of a month, you could go five months from the beginning of that month, then
subtract 1 day.
Terrence
what exactly is 4 months? What is four months from 31th Oct? Is
the 31st Feb, 28th Feb, 29th Feb, 1st Mar? Until you decide how
you need to return the date in these circumstances you are stuck. If
all you are trying to do is get the end of the month four months away
then you can do it via
select datetime(2004-12-1) year to day + 5 units month - 1 units day
Cheers
Paul
At a unix level if you tried it some Unix would error and give
you the same date back, some would return the next valid date.
"Terrence Mu...." wrote:
>
> All,
>
> I'm trying to get a date value that is 4 months from a given day. If I use:
>
> select datetime(2004-12-30) year to day + 4 units month from dummy
>
> I get 2005-04-30
>
> However, if I try:
>
> select datetime(2004-12-31) year to day + 4 units month from dummy
>
> I get an error:
> 1267: The result of a datetime computation is out of range.>
> I tried using + 120 day - but this doesn't always give you exactly 4 months.
>
> Am I out of luck here????
>
> -Terrence
--
Paul Watson #
Oninit Ltd # Growing old is mandatory
Tel: +44 1436 672201 # Growing up is optional
Fax: +44 1436 678693 #
Mob: +44 7818 003457 #
www.oninit.com #
Your privacy choices
We use strictly necessary cookies to make this site work. With your
consent we’d also use optional cookies for analytics and marketing. You can accept all,
reject all, or choose. Read our Cookie Policy.