home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Sams Cobol 24 Hours
/
Sams_Cobol_24_Hours.iso
/
source
/
ch21
/
CHAPT21F.COB
< prev
next >
Wrap
Text File
|
1998-09-14
|
4KB
|
75 lines
000010 @OPTIONS MAIN,TEST
000020 Identification Division.
000030 Program-Id. Chapt21f.
000031* Days Between Dates, With Weekday
000040 Environment Division.
000050 Configuration Section.
000051 Source-Computer. IBM-PC.
000055 Object-Computer. IBM-PC.
000056 Data Division.
000057 Working-Storage Section.
000058 01 First-Date Value Zeros.
000059 03 Date-MM Pic 99.
000060 03 Date-DD Pic 99.
000061 03 Date-YYYY Pic 9(4).
000062 01 Second-Date Value Zeros.
000063 03 Date-MM Pic 99.
000064 03 Date-DD Pic 99.
000065 03 Date-YYYY Pic 9(4).
000066 01 Days-Between Pic S9(12).
000076 01 Integer-First-Date Pic 9(12).
000077 01 Integer-Second-Date Pic 9(12).
000078 01 Date-Formatting-Items.
000079 03 YYYYMMDD-Format-Date.
000080 05 Date-YYYY Pic 9(4).
000081 05 Date-MM Pic 99.
000082 05 Date-DD Pic 99.
000083 03 YYYYMMDD-Format-Date-N
000084 Redefines YYYYMMDD-Format-Date Pic 9(8).
000085 01 Format-Indicator-F Pic X(8) Value "MMDDYYYY".
000086 01 Format-Indicator-S Pic X(8) Value "MMDDYYYY".
000087 01 Weekday-First Pic X(9) Value Spaces.
000088 01 Weekday-Second Pic X(9) Value Spaces.
000089 01 Weekday-Table-Area.
000090 03 Weekday-Table-Values.
000091 05 Filler Pic X(27) Value "Sunday Monday Tuesday".
000092 05 Filler Pic X(27) Value "WednesdayThursday Friday".
000093 05 Filler Pic X(9) Value "Saturday".
000094 03 Weekday-Table Redefines Weekday-Table-Values.
000095 05 The-Day Pic X(9) Occurs 7 Times.
000096 01 Remainder-Days Pic 9.
000097 Screen Section.
000098 01 Date-Entry Blank Screen Auto.
000099 03 Line 01 Column 01 Value "Enter First Date: ".
000100 03 Line 01 Column 21 Pic X(8) From Format-Indicator-F
000101 To First-Date.
000102 03 Line 01 Column 30 Pic X(9) From Weekday-First.
000103 03 Line 03 Column 01 Value "Enter Second Date: ".
000104 03 Line 03 Column 21 Pic X(8) From Format-Indicator-S
000105 To Second-Date.
000106 03 Line 03 Column 30 Pic X(9) From Weekday-Second.
000107 03 Line 05 Column 01 Value "Days between dates: ".
000108 03 Line 05 Column 21 Pic -Zzz,ZZ9 From Days-Between.
000109 Procedure Division.
000159 Chapt21f-Start.
000169 Display Date-Entry
000179 Accept Date-Entry
000180 Move Corresponding First-Date To YYYYMMDD-Format-Date
000181 Compute Integer-First-Date =
000182 Function Integer-Of-Date (YYYYMMDD-Format-Date-N)
000183 Move First-Date To Format-Indicator-F
000184 Move Corresponding Second-Date To YYYYMMDD-Format-Date
000185 Compute Integer-Second-Date =
000186 Function Integer-Of-Date (YYYYMMDD-Format-Date-N)
000187 Move Second-Date To Format-Indicator-S
000188 Compute Days-Between =
000189 Integer-Second-Date - Integer-First-Date
000190 Compute Remainder-Days =
000191 (Function Rem (Integer-First-Date 7) + 1)
000195 Move The-Day (Remainder-Days) To Weekday-First
000196 Compute Remainder-Days =
000197 (Function Rem (Integer-Second-Date 7) + 1)
000198 Move The-Day (Remainder-Days) To Weekday-Second
000202 Display Date-Entry
000203 Stop Run
000204 .