× 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.



Rob, 

Thanks for the assist - actually, it was a simple, old "Y2K fix" that solved 
the problem:

Select * from filename where filedate=(userdate + 19000000)
 
So... 
1060911 + 19000000 = 20060911 

How quickly I forgot something so basic, and boring, and mind-numbingly 
repititious
from the months leading up to the big "Y2K Disaster"!

Thanks again!



From: rob@xxxxxxxxx
Date: 2006/09/12 Tue AM 10:15:35 EDT
To: RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx>
Subject: Re: Date conditioned SQL Select

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
-- 
Group Dekko Services, LLC
Dept 01.073
PO Box 2000
Dock 108
6928N 400E
Kendallville, IN 46755
http://www.dekko.com





<klerpg@xxxxxxxxxxxxx> 
Sent by: rpg400-l-bounces@xxxxxxxxxxxx
09/11/2006 01:18 PM
Please respond to
RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx>


To
<rpg400-l@xxxxxxxxxxxx>
cc

Subject
Date conditioned SQL Select






All:

I have a file that I need to read based on a user-input date field 
(CCYYMMDD). The file field
I am comparing to is a 7 digit date field (CYYMMDD). 

In SQL, how do I get the select statement to pull records based on a 
comparison of these two 
fields?

TIA

-- 
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.


-- 
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.




As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.