There are a set of UDF's you can download to do this. I like Alan
Campin's idate. It is available at
http://www.think400.dk/downloads.htm
Your sample is pretty easy. Someone has to pass in a timestamp. Therefore
it already has to be valid. They can't pass you '2015-02-31-25.13.13'.
However, they can pass you a null value.
Validity checking, null values, etc, are all handled in idate. And it
costs nothing.
Rob Berendt
--
IBM Certified System Administrator - IBM i 6.1
Group Dekko
Dept 1600
Mail to: 2505 Dekko Drive
Garrett, IN 46738
Ship to: Dock 108
6928N 400E
Kendallville, IN 46755
http://www.dekko.com
From: "Lunde, Peter" <plunde-ETsMpvZGyKKX5PeLeEhoL7Dks+cytr/[email protected]>
To: "'bpcs-l-Zwy7GipZuJhWk0Htik3J/[email protected]'" <bpcs-l-Zwy7GipZuJhWk0Htik3J/[email protected]>
Date: 11/10/2015 11:55 AM
Subject: [BPCS-L] SQL UDF to Convert Today's Date to Dec(8,0)
Sent by: "BPCS-L" <bpcs-l-bounces-Zwy7GipZuJhWk0Htik3J/[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.
--
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.