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

  1. 000010 @OPTIONS MAIN,TEST
  2. 000020 Identification Division.
  3. 000030 Program-Id.  Chapt21f.
  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 01  Format-Indicator-F    Pic X(8) Value "MMDDYYYY".
  30. 000086 01  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  Remainder-Days Pic 9.
  41. 000097 Screen Section.
  42. 000098 01  Date-Entry Blank Screen Auto.
  43. 000099     03  Line 01 Column 01 Value "Enter First Date: ".
  44. 000100     03  Line 01 Column 21 Pic X(8) From Format-Indicator-F
  45. 000101                                    To   First-Date.
  46. 000102     03  Line 01 Column 30 Pic X(9) From Weekday-First.
  47. 000103     03  Line 03 Column 01 Value "Enter Second Date: ".
  48. 000104     03  Line 03 Column 21 Pic X(8) From Format-Indicator-S
  49. 000105                                    To   Second-Date.
  50. 000106     03  Line 03 Column 30 Pic X(9) From Weekday-Second.
  51. 000107     03  Line 05 Column 01 Value "Days between dates: ".
  52. 000108     03  Line 05 Column 21 Pic -Zzz,ZZ9 From Days-Between.
  53. 000109 Procedure Division.
  54. 000159 Chapt21f-Start.
  55. 000169     Display Date-Entry
  56. 000179     Accept Date-Entry
  57. 000180     Move Corresponding First-Date To YYYYMMDD-Format-Date
  58. 000181     Compute Integer-First-Date =
  59. 000182             Function Integer-Of-Date (YYYYMMDD-Format-Date-N)
  60. 000183     Move First-Date To Format-Indicator-F
  61. 000184     Move Corresponding Second-Date To YYYYMMDD-Format-Date
  62. 000185     Compute Integer-Second-Date =
  63. 000186             Function Integer-Of-Date (YYYYMMDD-Format-Date-N)
  64. 000187     Move Second-Date To Format-Indicator-S
  65. 000188     Compute Days-Between =
  66. 000189            Integer-Second-Date - Integer-First-Date
  67. 000190     Compute Remainder-Days =
  68. 000191             (Function Rem (Integer-First-Date 7) + 1)
  69. 000195     Move The-Day (Remainder-Days) To Weekday-First
  70. 000196     Compute Remainder-Days =
  71. 000197             (Function Rem (Integer-Second-Date 7) + 1)
  72. 000198     Move The-Day (Remainder-Days) To Weekday-Second
  73. 000202     Display Date-Entry
  74. 000203     Stop Run
  75. 000204     .