|
i know this is not a formula but can you just subtract 1 from the year and build the select statement like this: move inputyear tyeara 4 eval inputyear = inputyear -1 move inputyear fyeara 4 move inputperiod perioda 2 eval sqlstm = 'select * from table where (digits(year)||digits(period)) > "' + fyeara + perioda + '" and (digits(year)||digits(period)) <= "' + tyeara + perioda + '"' ----- Original Message ----- From: "Mike Wills" <koldark@xxxxxxxxx> To: "RPG programming on the AS400 / iSeries" <rpg400-l@xxxxxxxxxxxx> Sent: Wednesday, January 04, 2006 6:31 PM Subject: Formula Question Okay, this may be a difficult one. I have a simple table layout like this. Company (4,0) Year(4,0) Period(2,0) Amount(15,2) I want to be able to take an ending period and determine 12 months back from the ending date and select records in the DB via a select statement. We are really close with the following formula: ( ( ( (period-12) / (period-12) ) * 12 ) - 11 )+period. A co-worker of mine got this far. If it wasn't for the whole divide by zero bit as this portion ( (period-12)/(period-12) ) would for period 12, it would work great. Short of a case statement is there a better way to handle divide by zero? Or is the a better formula that we aren't seeing? -- Mike Wills koldark@xxxxxxxxx http://mikewills.name Want Gmail? Email koldark+gmail@xxxxxxxxx to get on my waiting list. "There are 10 types of people in the world: those who understand binary, and those who don't." -Unknown
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.