Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Subtract" Statements 2

Status
Not open for further replies.

mcobolahan

Technical User
Feb 7, 2001
2
0
0
US
I have to calculate the seniority of an individual as of the year 1995.
Hence, if Bob was hired in 2/18/79, his seniority would be (95-79).

How can I subtract the year field from 95 if the input is in the form: XX/XX/XX?

*The calculated result can only be 2 bytes long
 
Hi Mac,

If your date fields are defined like this:
Code:
        05  ws-date        pic x(008).

Define them or redefine them like this:

        05  ws-date        pic  x(008).
        05  ws-date-red    redefines
            ws-date. 
            10  ws-mm-red  pic s9(002).
            10  fil        pic  x(001).  
            10  ws-dd-red  pic s9(002).
            10  fil        pic  x(001).
            10  ws-yy-red  pic s9(002).
Now you can subtract yy of date1 from yy of date2.
Note that the digits were redefined as pic 9 to allow arithmetic functions to be performed.

Hope this helps. Jack.

 
...
Working-storage Section.
01 date1 pic x(08).
01 year1 pic 99.
01 valor pic 99 value zeroes.
Procedure Division.
Calc-Result.
move '02/18/79' to date1.
move date1(7:2) to year1.
compute valor = 95 - year1.
display 'difference: ' valor.
stop run.


==================
learning & sharing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top