#16 UDF suggestion for dates

open
nobody
None
5
2003-07-25
2003-07-25
Anonymous
No

I've got a variety of scripts that require today's date in
decimal form, either 7 or 8 digits (YYYMMDD or
YYYYMMDD). I've been stuck on v4r4 until last week,
and didn't have a C compiler to create a function to
handle this, so I was regularly substringing out pieces of
now() or curdate().

Those still stuck without a compiler (or much RPG skills)
could probably make alot of use out of such a function.

Presently, I'm now using the following. I imagine an RPG
version that could work on compilerless boxes would
take someone just a few minutes to create.

create function today8() returns decimal(8,0)
language sql
begin
return (decimal(substr(char(now()),1,4) || substr(char
(now()),6,2) || substr(char(now()),9,2)));
end;

create function today7() returns decimal(7,0)
language sql
begin
return (decimal('2' || substr(char(now()),3,2) || substr
(char(now()),6,2) || substr(char(now()),9,2)));
end;

Discussion


Log in to post a comment.