Re: Variable set
Posted in 1998
On Fri, 10 Jul 1998, ABEL ROJAS GARCIA wrote:
> Hello, does anybody knows a variable to set the format when I insert a
> value DATE?
>
> I want to use "98-01-01 00:00:00000" without DATETIME YEAR TO FRACTIONS.
The documentation would imply that DBTIME is the variable to set.
Actually, though, I am 99.99% confident that it will do nothing for you.
Missing the 1900 from 1998 will make life difficult. I'm not clear what
the 5 zeroes at the end mean? Is that a 5-digit seconds field, or a
FRACTION(3) with an implicit decimal point? And if it's the latter, what
sort of (brain-dead?) software produced that output format?
Assuming that there isn't an implicit fractional part, I'd do the
translation with my DBLDFMT command, which is available in the IIUG
archives (www.iiug.org).
In principle, this is a time conversion, so for each such time field in the
data, you'd specify a time conversion such as:
-t r=1-20,i="%y-%m-%d %H:%M:%S",o="%Y-%m-%d %H:%M:%S"
The code in DBLDFMT uses the strptime(3) function required by X/Open
Unix-98 (and strftime(3) required by ANSI/ISO C, so that's seldom a
problem). However, the str[fp]time routines do not handle fractional
seconds; consequently, DBLDFMT does not handle fractional seconds.
I guess the code could be extended to process the fractional seconds
separately -- I haven't done so yet because I've had no reason to do
so yet.
DBLDFMT does handle implicit decimal points in ordinary decimal fields;
I guess you could fix this up with two passes over the data. Also, it
can combine constants with other fields, so you can do a much simpler
textual conversion:
-f c="19",d=1-20.3
For example:
$ echo "98-06-23 12:34:45678" | dbldfmt -l 20 -f c=19,d=1-20.3
1998-06-23 12:34:45.678|
$
Alternatively, you could write a Perl/Sed/Awk script to place 19 in
front of the datetime fields -- and place the decimal point
Yours,
Jonathan Leffler (jleffler@informix.com) #include <witticism.h>
Guardian of DBD::Informix -- see http://www.perl.com/CPAN