Re: DATE and UNITS problem
Posted in 1995
Topics: Stored Procedures & SPL, Connectivity: ESQL/C, 4GL & Embedded SQL, Server Administration
In article AA00727@alvin.180.8.233.1, alvinkoh@pts7.pts.mot.com (Alvin Koh) writes: > I have a 4gl program that uses the DATE and UNITS as in > > main > define d1 date > define d2 date > let d1 = "1/31/1995" > let d2 = d1 + 1 units month > display d2 > end main > > The program fails because it trys to assign d2 a value of "2/31/1995" which > is of course an invalid date and results in the following error: > > FORMS statement error number -1267. > The result of a datetime computation is out of range. > > I am using ONLINE 5.01.UD2 and 4GL RDS 4.11.UC2. I have also got similar > results on ONLINE 5.03.UC1 and 4GL RDS 4.12.UE1. Has anyone encountered this? > Is this a known "bug" and what is the workaround? > > Thanks. > > > -------------------------------------------------------------------------------- > Alvin Koh Internet: Alvin_Koh@email.mot.com > Senior Systems Engineer, MIS alvinkoh@pts7.pts.mot.com > Motorola Electronics Pte Ltd - AMK Phone: +65 486-2055 > Paging Products Group Fax: +65 481-2840 > Asia/Pacific Paging Subscriber Division > -------------------------------------------------------------------------------- > Alvin, Yes, this is a known problem. I don't know if Informix has formally said it is a bug, but it certainly is a problem. We use something similar here. Our needs have been to calculate the first or last of the month given the other. What we found was that if we were given the first of the month and we wanted to calculate the end of the month we would use the following: let first_mon = "1/1/95" let end_mon = first_mon + 1 units month let end_mon = end_mon - 1 unit day However, in doing this we found a problem at the end of the year. I don't remember the exact error or date that was returned, but I know it wasn't correct. So, we decided to use the last day of the month and work our way backwards to the first. We did this using the following: let end_mon = "1/31/95" let first_mon = end_mon + 1 units day let first_mon = first_mon - 1 units month This will then set first_mon = "1/1/95". When we spoke to Informix about this issue we were told that we could write a C program to take care of it. Instead we use the second option I outlined. I hope this helps! Debbie Shelton DBA McCaw Cellular Communications, Inc. debbie.shelton@mccaw.com
Related threads
- Date-field - #months : 1267: The result of a datetime computation is out of range.
- Re: Leap Year
- Is this an informix leap year bug?