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



Is CALY a numeric variable? Then this is still not working - you must have left out something.

And this is exactly what several of us gave you 2 days ago. I'm sorry to sound kind of testy, but really, we all did give you this solution. By the way, the double bars are the same as the concat operator, except, as Rob said, they are a bad idea in global language machines.

So it looks as if you need the DIGITS function around CALY and you should replace || with concat.

Regards
Vern

Chandana Silva wrote:
Thank you, Doug.

You helped me to clear my brain cell clog with the concat :-) Discovery is the mission !

I want to share the final result, which is nice and clean.

Select sum(SALES) From DaySALES
WHERE CPY = 22 and STR = 1234 AND
CALY || DIGITS(CALM) || DIGITS(CALD) BETWEEN '20090714' AND '20090810';
I am using host values for the BETWEEN :FrmDate And :Todate and in cpy and str,in my actual code.
Performance : Statement ran successfully (31 ms) - via iseries navigator

Greatly Appreciate all the nice people, who share their skills to educate others.

________________________________
From: Doug Davie <dougdavie@xxxxxxxxx>
To: RPG programming on the IBM i / System i <rpg400-l@xxxxxxxxxxxx>
Sent: Tue, February 2, 2010 4:43:41 AM
Subject: Re: AW: SQL Date Range Problem with Between - Resolved

where concat(caly,concat(calm,cald))
between '20090714' and '20090810'



On Tue, Feb 2, 2010 at 3:49 AM, CRPence <CRPbottle@xxxxxxxxx> wrote:

Chandana Silva wrote:
<<SNIP>>

The Concatenation below works but the results are bad ..
Select sum(SALES)
From DaySales
WHERE CPY = 22 and SDSTR = 1234 AND
DIGITS(2009) CONCAT'-' CONCAT DIGITS (07) CONCAT'-'
CONCAT DIGITS(15) BETWEEN '2009-07-14' AND '2009-08-10';

I tried:
Select sum(SALES)
From DaySales WHERE CPY = 22 and SDSTR = 1234 AND
DIGITS(2009) CONCAT DIGITS (07) CONCAT DIGITS(15)
BETWEEN '20090714' AND '20090810';

Off by Ml.s
Suggesting that "results are bad" and "off by Ml.s" is not
helpful to those who might choose to assist.

The DIGITS() function will not automatically cast to a character
string matching the length of the numeric literal. The numeric
field or literal will need to have exactly two-digits in precision,
or must be CAST as such [before casting to its DIGITS character
string form]. The literals will be treated as integer, which have
a precision of ten. Per that error, the latter requests the
equivalent of:
"AND '000000200900000000070000000015' BETWEEN '20090714'..."

Multiplication below, Returns Zeo (.)

Select sum(SALES)
From DaySales WHERE SDCPY = 88 and SDSTR = 1234 AND
((2009*10000) + (07*100) + 15) BETWEEN '20090714' AND
'20090810';
<<SNIP>>

Similar to the prior poor explanation of results, what does
"returns zeo (.)" mean? Perhaps "zero records"? Seems odd, since
even though the expression is numeric and the comparison values are
character strings, the implicit cast of either should give the
results just as if all were instead, proper DATE data type values.

Regards, Chuck
--
This is the RPG programming on the IBM i / System i (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 ...

Replies:

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.