3

I have difficulties with a query I have to change to limit the data I export from a Progress database. I export "myorderdate" to a text file. However, I have to limit the data to only orders after year 2012.

OUTPUT STREAM s1 TO VALUE(exportFileStringDirectory).
FOR EACH poTable NO-LOCK WHERE
 ponum = 1 AND
 /* this doesn't work -->*/
 /*myorderdate.YEAR >= DATE("2012").YEAR AND*/
 conum = 1:

 PUT STREAM s1 UNFORMATTED
    ISO-DATE(myorderdate)
 SKIP. 
END.
OUTPUT STREAM s1 CLOSE.

I'm new to Progress 4GL databases and work with databases altogether. All I have to do is a small change to the code so please forgive me if the description lacks some vital information.

DamianS1987
  • 302
  • 1
  • 3
  • 13

2 Answers2

5

I would code it like this:

FOR EACH poTable NO-LOCK WHERE
 ponum = 1 AND conum = 1 and 
 myorderdate >= 1/1/2012:

That way you avoid having to evaluate the YEAR() function with every iteration of the loop.

Tom Bascom
  • 13,405
  • 2
  • 27
  • 33
4

Use YEAR function. YEAR() function takes input as date and returns year value of the date as an integer.

So, replace

myorderdate.YEAR >= DATE("2012").YEAR

with:

YEAR(myorderdate) >= 2012
Austin
  • 1,237
  • 1
  • 11
  • 22