× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I want to convert to a date field, then
> select records where FAILDT <=
CURRENT DATE - 5 Years.

Consider creating an SQL user defined function. Write the function in RPG IV to convert the 8s 0 to a D data type and then you can use CREATE FUNCTION returns DATE. Look up Scalar External functions in the SQL reference. I'm pretty sure there are examples in the faq at http://faq.midrange.com.

The beauty of a UDF is that you can write it in RPG, test and debug it in your usual environment, and then do a CREATE FUNCTION to 'register' your existing code with SQL. Then you can do SELECT ... where eight2date(faildt) <= CURRENT DATE - 5

And did I mention that you can register a service program subprocedure, too? So if you write 'eight2date' as a subprocedure, you can use it in all of your RPG programs as well as in SQL statements! The exact same code, all in one place. OS400 is pretty slick.

  --buck

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.