123 Eng

Engineering the engineers™


Latest Jobs   Forum Map

 


Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

   Computer Science / IT
   Electronics
   Electrical
   Mechanical
   Chemical
   Civil

   CAT / MBA

   GMAT / Foreign MBA
Latest Jobs

Engineering Jobs / Technical Jobs
Management Jobs

Sitemap
Terms of use

Displaying  Source Code(s)  
 

 
Date Difference in Mainframe COBOL

--------------------------------------------------------------------------------

Description : This program finds the difference between two dates given from the JCL.


IDENTIFICATION DIVISION.
00010000
PROGRAM-ID. CDATEC.
00020000

00021000
DATA DIVISION.
00030000

00031000
WORKING-STORAGE SECTION.
00040000

00041000
01 YR PIC 9999.
00050000

00051000
01 YR1 PIC 9999.
00060000

00060100
01 YR2 PIC 9999.
00061000

00062000
01 MON PIC 99.
00070000

00071000
01 MON1 PIC 99.
00080000

00080100
01 MON2 PIC 99.
00081000

00082000
01 D1 PIC 99.
00090000

00091000
01 D2 PIC 99.
00100000

00101000
01 QU1 PIC 99.
00110000

00111000
01 REM1 PIC 99.
00120000

00121000
01 REM2 PIC 99.
00130000

00131000
01 REM3 PIC 99.
00140000

00141001
01 T PIC 99999999.
00150000

00150101
01 T1 PIC 99999999.
00151000

00151101
01 T2 PIC 99999999.
00152000

00153001
PROCEDURE DIVISION.
00160000

00161001
MAINP.
00170000
ACCEPT YR1.
00180000
ACCEPT YR2.
00190000
ACCEPT MON1.
00200000
ACCEPT MON2.
00210000
ACCEPT D1.
00220000
ACCEPT D2.
00230000

00240001
PERFORM LP-PARA VARYING YR FROM 1900 BY 1 UNTIL YR = YR1.
00270000
PERFORM MN-PARA VARYING MON FROM 1 BY 1 UNTIL MON = MON1.
00280000

00281001
MOVE T TO T1.
00290000
COMPUTE T1 = T1 + D1.
00290100
MOVE 0 TO T.
00291000

00292001
PERFORM LP-PARA VARYING YR FROM 1900 BY 1 UNTIL YR = YR2.
00330000
PERFORM MN-PARA VARYING MON FROM 1 BY 1 UNTIL MON = MON2.
00340000

00341001
MOVE T TO T2.
00350000
COMPUTE T2 = T2 + D2.
00350100
COMPUTE T = T2 - T1.
00351000

00352001
DISPLAY "THE DIFFERENCE BETWEEN DATES: ".
00360000
DISPLAY D1 "/" MON1 "/" YR1 " & " D2 "/" MON2 "/" YR2 " IS<BR>.00361000
DISPLAY T.
00362000
STOP RUN.
00370000

00371001
LP-PARA.
00380000
DIVIDE YR BY 400 GIVING QU1 REMAINDER REM1.
00381000
DIVIDE YR BY 100 GIVING QU1 REMAINDER REM2.
00382000
DIVIDE YR BY 4 GIVING QU1 REMAINDER REM3.
00383000
IF REM1 = 0 OR ( REM2 IS NOT = 0 AND REM3 = 0 ) THEN
00390000
COMPUTE T = T + 366
00400000
ELSE
00410000
COMPUTE T = T + 365
00420000
END-IF.
00430000

00431001
MN-PARA.
00440000
DIVIDE YR BY 400 GIVING QU1 REMAINDER REM1.
00441000
DIVIDE YR BY 100 GIVING QU1 REMAINDER REM2.
00442000
DIVIDE YR BY 4 GIVING QU1 REMAINDER REM3.
00443000
IF MON = 1 OR MON = 3 OR MON = 5 OR MON = 7 OR MON = 8
00450000
OR MON = 10 OR MON = 12 THEN
00460000
COMPUTE T = T + 31
00470000
ELSE IF MON = 4 OR MON = 6 OR MON = 9 OR MON = 11 THEN
00480000
COMPUTE T = T + 30
00490000
ELSE IF REM1 = 0 OR ( REM2 IS NOT = 0 AND REM3 = 0 ) THEN
00500000
COMPUTE T = T + 29
00510000
ELSE
00520000
COMPUTE T = T + 28
00530000
END-IF.
00540000
--------------------------------------------------------------------------------

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved © copyright 123ENG