Re: 4GL DateTime Variables
Posted in 1991
Path: emory!sol.ctr.columbia.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!rutgers!pyrnj!pyramid!infmx!aland
From: aland@informix.com (Colonel Panic)
Newsgroups: comp.databases.informix
Message-ID: <1991Nov16.232255.9550@informix.com>
Date: 16 Nov 91 23:22:55 GMT
References: <20490001@hpspkla.spk.hp.com> <1991Nov14.182028.11657@informix.com>
Sender: news@informix.com (Usenet News)
Organization: International Brotherhood of Geeks, Local 619
In article <1991Nov14.182028.11657@informix.com> johnl@informix.com (Jonathan Leffler) writes:
>In article <20490001@hpspkla.spk.hp.com> engstrom@hpspkla.spk.hp.com
>(Kathleen Engstrom) writes:
>>Hi
>>
>>I'm fairly new to the world of I4GL programming. I'm trying to format
>>some datetime variables. I was able to use expand to break it up and
> EXTEND?
>>get just the date portion of the variable, but I haven't found anything
>>that will allow me to format the result. (This is in a report)
>
>There are basically no formatting routines for DATETIME. You can convert a
>DATETIME YEAR TO DAY into a DATE by DATE(dtime), and then format as with any
>other date -- that's easiest.
>
>You can assign a DATETIME to a string, but the string is right-justified (I
>know not why -- it just is!). You can then disembowel the string in any way
No, it isn't. I just tried it. Bloody liar! [-:
>which takes your fancy. Incidentally, if you find you need to order by a
>datetime variable inside a report (ORDER {INTERNAL} BY), your C4GL compiler may
>have a fit; use a character string instead of a DATETIME and you'll be OK,
>even if you pass a DATETIME into the report.
Also works OK if you use ORDER EXTERNAL BY, which is always preferred if
the data is sent to the report already in order. Even if it compiles,
you'll get errors at runtime. This is a bug (bug #11382, for the record).
>>I would like to put the date in a more human readable form. (i.e. 11/7/91
>>instead of 91-11-7).
See my prior post.
>>My second question: I would like to calculate the difference in two dates
>>and then subtract out weekends and holidays from the result. I would
>>appreciate any pointers, suggestions on how to do that cleanly. A turnkey
>>application would be even better :-)
>
>Non-trivial, to put it mildly. With random holidays (such as Easter,
>Christmas) as well as weekends, the technique I use is:
>
>DEFINE d, date_1, date_2 DATE
>DEFINE dn, i INTEGER
>CREATE TEMP TABLE T1 (counter SERIAL, wanted DATE) WITH NO LOG;
If you are using 4.00 RDS, don't use WITH NO LOG; it doesn't work right.
This is fixed in 4.10.
...
>Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>
--
Alan Denney aland@informix.com {pyramid|uunet}!infmx!aland
"J.F.K. flew down to Dallas
To cool some heels in the Oil Palace
Unfriendly country, but he was unafraid Was (not Was)
He would wave to the people from a passing motorcade." "11 Miles Per Hour"