Re: 4GL DateTime Variables
Posted in 1991
Path: emory!swrinde!mips!zaphod.mps.ohio-state.edu!wupost!uunet!trac2000!das13!dave From: dave@das13.snide.com (Dave Snyder) Newsgroups: comp.databases.informix Message-ID: <1536@das13.snide.com> Date: 14 Nov 91 14:56:52 GMT References: <20490001@hpspkla.spk.hp.com> Organization: Snide Inc. - Folcroft, PA In article <20490001@hpspkla.spk.hp.com>, engstrom@hpspkla.spk.hp.com (Kathleen Engstrom) writes: > 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 > 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) > > I would like to put the date in a more human readable form. (i.e. 11/7/91 > instead of 91-11-7). > This is what I'd do... I'd call an ESQL/C function that does the following: 1) Use dtextend() to adjust the DATETIME qualifier to "year to day" 2) Use dttoasc(), creating a character string in the form "yyyy-mm-dd" 3) Use rdefmtdate() with a pattern argument of "yyyy-mm-dd" to convert the string to a DATE. The returned DATE variable can then be printed in any format you want with the USING clause. BTW, if you are using RDS, you'll need to create a new fglgo containing this custom function. > 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 :-) > DATE variables are stored internally as longs. You can subtract two dates and come up with a difference in days... subtracting weekends from that result would require a little thought, however subtracting holidays would be damn near impossible since quite a few holidays don't fall on the same day every year. Also, who says a certain day is a holiday? Veteran's Day is a holiday for bankers, but not for me. Black Friday is a holiday for me, but not bankers. Have fun... DAS -- David A. Snyder @ Snide Inc. - Folcroft, PA Current Release is db4glgen-3.2 UUCP: ..!uunet!das13!dave INTERNET: Dave.Snyder@snide.com