home *** CD-ROM | disk | FTP | other *** search
/ Sams Cobol 24 Hours / Sams_Cobol_24_Hours.iso / source / ch21 / CHAPT21D.COB < prev    next >
Text File  |  1998-09-14  |  4KB  |  78 lines

  1. 000010 @OPTIONS MAIN,TEST
  2. 000020 Identification Division.
  3. 000030 Program-Id.  Chapt21d.
  4. 000031* Days Between Dates, With Weekday
  5. 000040 Environment Division.
  6. 000050 Configuration Section.
  7. 000051 Source-Computer.  IBM-PC.
  8. 000055 Object-Computer.  IBM-PC.
  9. 000056 Data Division.
  10. 000057 Working-Storage Section.
  11. 000058 01  First-Date    Value Zeros.
  12. 000059     03  Date-MM           Pic 99.
  13. 000060     03  Date-DD           Pic 99.
  14. 000061     03  Date-YYYY         Pic 9(4).
  15. 000062 01  Second-Date   Value Zeros.
  16. 000063     03  Date-MM           Pic 99.
  17. 000064     03  Date-DD           Pic 99.
  18. 000065     03  Date-YYYY         Pic 9(4).
  19. 000066 01  Days-Between          Pic S9(12).
  20. 000076 01  Integer-First-Date    Pic  9(12).
  21. 000077 01  Integer-Second-Date   Pic  9(12).
  22. 000078 01  Date-Formatting-Items.
  23. 000079     03  YYYYMMDD-Format-Date.
  24. 000080         05  Date-YYYY         Pic 9(4).
  25. 000081         05  Date-MM           Pic 99.
  26. 000082         05  Date-DD           Pic 99.
  27. 000083     03  YYYYMMDD-Format-Date-N
  28. 000084         Redefines YYYYMMDD-Format-Date Pic 9(8).
  29. 000085     03  Format-Indicator-F    Pic X(8) Value "MMDDYYYY".
  30. 000086     03  Format-Indicator-S    Pic X(8) Value "MMDDYYYY".
  31. 000087 01  Weekday-First         Pic X(9) Value Spaces.
  32. 000088 01  Weekday-Second        Pic X(9) Value Spaces.
  33. 000089 01  Weekday-Table-Area.
  34. 000090     03  Weekday-Table-Values.
  35. 000091         05  Filler Pic X(27) Value "Sunday   Monday   Tuesday".
  36. 000092         05  Filler Pic X(27) Value "WednesdayThursday Friday".
  37. 000093         05  Filler Pic X(9)  Value "Saturday".
  38. 000094     03  Weekday-Table Redefines Weekday-Table-Values.
  39. 000095         05  The-Day    Pic X(9) Occurs 7 Times.
  40. 000096 01  Weeks              Pic 9(12) Value Zeros.
  41. 000097 01  Remainder-Days     Pic 9.
  42. 000098 Screen Section.
  43. 000099 01  Date-Entry Blank Screen Auto.
  44. 000100     03  Line 01 Column 01 Value "Enter First Date: ".
  45. 000101     03  Line 01 Column 21 Pic X(8) From Format-Indicator-F
  46. 000102                                    To   First-Date.
  47. 000103     03  Line 01 Column 30 Pic X(9) From Weekday-First.
  48. 000104     03  Line 03 Column 01 Value "Enter Second Date: ".
  49. 000105     03  Line 03 Column 21 Pic X(8) From Format-Indicator-S
  50. 000106                                    To   Second-Date.
  51. 000107     03  Line 03 Column 30 Pic X(9) From Weekday-Second.
  52. 000108     03  Line 05 Column 01 Value "Days between dates: ".
  53. 000109     03  Line 05 Column 21 Pic -Zzz,ZZ9 From Days-Between.
  54. 000110 Procedure Division.
  55. 000159 Chapt21d-Start.
  56. 000169     Display Date-Entry
  57. 000179     Accept Date-Entry
  58. 000180     Move Corresponding First-Date To YYYYMMDD-Format-Date
  59. 000181     Compute Integer-First-Date =
  60. 000182             Function Integer-Of-Date (YYYYMMDD-Format-Date-N)
  61. 000183     Move First-Date To Format-Indicator-F
  62. 000184     Move Corresponding Second-Date To YYYYMMDD-Format-Date
  63. 000185     Compute Integer-Second-Date =
  64. 000186             Function Integer-Of-Date (YYYYMMDD-Format-Date-N)
  65. 000187     Move Second-Date To Format-Indicator-S
  66. 000188     Compute Days-Between =
  67. 000189            Integer-Second-Date - Integer-First-Date
  68. 000190     Divide Integer-First-Date By 7 Giving Weeks
  69. 000191                                 Remainder Remainder-Days
  70. 000192     Add 1 To Remainder-Days
  71. 000193     Move The-Day (Remainder-Days) To Weekday-First
  72. 000194     Divide Integer-Second-Date By 7 Giving Weeks
  73. 000195                                  Remainder Remainder-Days
  74. 000196     Add 1 To Remainder-Days
  75. 000197     Move The-Day (Remainder-Days) To Weekday-Second
  76. 000198     Display Date-Entry
  77. 000199     Stop Run
  78. 000201     .