|
Frankly I like the way RPG handles date manipulation better than SQL. And while we can enhance SQL by using UDF's and our RPG it would be better if SQL were enhanced. Actually, the idea solution would be to stop using numeric fields to store dates. Another good case where a DBA could slap the fellow silly that still creates files with numeric dates. But, getting back to RPG vs SQL... Take this example: d DateCYMD s 7p 0 inz(1060901) d DateISO s 8p 0 inz(20060915) d Spread s 5i 0 /free Spread = %diff(%date(DateISO:*ISO):%date(DateCYMD:*CYMD):*days); dsply spread; // Value displayed was +14 *inlr=*on; return; /end-free Now, to do this in SQL would require a lot of manipulation of that silly cymd date. Something like d InputDate s 8p 0 inz(20060915) d InputTrue s d d InputDays s 5i 0 /free // Do as much calculation as possible OUTSIDE of the cursor so // as not to repeat the calculation on each row. InputTrue=%date(InputDate:*ISO); exec sql Set :InputDays = days(InputTrue); exec sql Declare C1 cursor for Select Amt From klerpg Where :InputDays - days( and here is where it gets tricky and I just don't have the time to do a good sample. I recommend you create a UDF to do this: http://faq.midrange.com/data/cache/185.html And submit a DCR to IBM to get them to enhance SQL. https://www-912.ibm.com/r_dir/ReqDesChange.nsf/Request_for_Design_Change?OpenForm Rob Berendt
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.