SQL UDF to Convert Today's Date to Dec(8,0)

"Lunde, Peter" <plunde-ETsMpvZGyKKX5PeLeEhoL7Dks+cytr/[email protected]>
Newsgroups gmane.comp.systems.as400.bpcs
Message-ID <[email protected]>
Hi Everyone:

I have created my first SQL user defined function (UDF)!

This UDF coverts a timestamp, including today's date, into a dec(8,0) so that you can compare it to BPCS or LX dates.

Then, you can (for example) change expired lots to status E.

Here is the code...

create function MyObjLib/yyyymmdd(TS timestamp)
returns dec(8,0)
language sql
begin
return cast(rtrim(char(year(TS)))||substr( digits (month(TS)),9)
||substr( digits (day(TS)),9) as dec(8,0));
end


update iln set lmrb='E' where lexdt > 0 and lexdt < MyObjLib/yyyymmdd(current timestamp) and lmrb in('A','C','Q')


What do you think?

Best Regards,

Peter

[cid:image001.png-ck5USyoaq+0reE8X+F/[email protected]]

Peter Lunde, BASc, MBA
Manager, Information Technology
WellSpring Pharmaceutical Canada Corp.
400 Iroquois Shore Rd
Oakville, ON, L6H 1M5
plunde-ETsMpvZGyKKX5PeLeEhoL7Dks+cytr/[email protected]<mailto:plunde-ETsMpvZGyKKX5PeLeEhoL7Dks+cytr/[email protected]>
We Believe in the Power of Our Chemistry.


-- 
This is the BPCS ERP System (BPCS-L) mailing list
To post a message email: BPCS-L-Zwy7GipZuJhWk0Htik3J/[email protected]
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/bpcs-l
or email: BPCS-L-request-Zwy7GipZuJhWk0Htik3J/[email protected]
Before posting, please take a moment to review the archives
at http://archive.midrange.com/bpcs-l.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.