Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Exactly what are you having trouble with? COBOL or the algorithm? I'm guessing its COBOL.</p> <p>I'm not going to give you a direct answer because you are obviously leaning the language and there is value in working out the specific details for yourself.</p> <p>Here are a couple of hints:</p> <p>Define a date field in <code>WORKING-STORAGE</code> so that you can pick out the day, month and year as separate items. Something like:</p> <pre><code>01 TEST-DATE. 05 TEST-DAY PIC 99. 05 PIC X. 05 TEST-MONTH PIC 99. 05 PIC X. 05 TEST-YEAR PIC 9999. </code></pre> <p>Note the unnamed <code>PIC X</code> fields. These contain the day/month/year delimiters. They do not need to be given data names because you do not need to reference them. Sometimes this type of data item is given the name <code>FILLER</code>, but the name is optional. </p> <p>Read up on the <code>EVALUATE</code> statement. Here is a <a href="http://publib.boulder.ibm.com/infocenter/pdthelp/v1r1/index.jsp?topic=/com.ibm.entcobol.doc_4.1/PGandLR/tasks/tpaid02.htm" rel="nofollow">link</a> to the IBM Enterprise COBOL manual. This description of <code>EVALUATE</code> should be similar in all versions of COBOL.</p> <p><code>MOVE</code> the date of interest <code>TO TEST-DATE</code>. Now you can reference the year, month and day as individual items: <code>TEST-DAY</code>, <code>TEST-MONTH</code> and <code>TEST-YEAR</code>.</p> <p>Use <code>EVALUATE</code> to test the month (<code>TEST-MONTH</code>). If the month is a 30 day month then <code>MOVE</code> 30 to <code>TEST-DAY</code>. Do the same for 31 day months. February is a special case because of leap years. Once you have determined that the month is February, test <code>TEST-YEAR</code> to <a href="http://en.wikipedia.org/wiki/Leap_year" rel="nofollow">determine if it is a leap year</a> and <code>MOVE</code> 28 or 29 TO <code>TEST-DAY</code> depending on the outcome of the test.</p> <p>Now <code>TEST-DATE</code> will contain the date you are looking for. <code>MOVE</code> it to wherever it is needed.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload