Logo 
Search:

Cobol Articles

Submit Article
Home » Articles » Cobol » Homework HelpRSS Feeds

Program of date manipulation

Posted By: Kuhlbert Schmidt     Category: Cobol     Views: 4284

Write a Program of date manipulation.

Code for Program of date manipulation in Cobol


       IDENTIFICATION DIVISION.
       PROGRAM-ID. 

       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 DATE1.
           02 YY    PIC 99.
           02 MM    PIC 99.
           02 DD    PIC 99.
       01 BIRDATE.
           02 BYY  PIC 9999.
           02 BMM  PIC 99.
           02 BDD  PIC 99.
       PROCEDURE DIVISION.
       MAIN-PARA.
           DISPLAY "-----------------------------------------------".
           ACCEPT DATE1 FROM DATE.
           DISPLAY " CURRENT DATE:- " DD "/" MM "/" YY.
           DISPLAY "-----------------------------------------------".
           DISPLAY " ENTER THE BIRTH-DATE(YYYYMMDD):- ".
           ACCEPT BIRDATE.
           COMPUTE YY = YY + 1906.
           IF  YY < BYY
                DISPLAY " DATE IS INVALID "
                EXIT
           ELSE
                IF MM < BMM
                        COMPUTE BMM = 12 - BMM
                        COMPUTE BMM = MM + BMM
                        COMPUTE BYY = BYY - 1
                ELSE IF MM = BMM AND DD < BDD
                        COMPUTE BYY = BYY - 1
                        COMPUTE BMM = MM - BMM

                ELSE
                        COMPUTE BMM = MM - BMM.


                IF DD < BDD
                        COMPUTE BDD = 30 - BDD
                        COMPUTE BDD = DD + BDD 
                        COMPUTE BMM = MM - 1
                ELSE
                        COMPUTE BDD = DD - BDD.

                DISPLAY ( 15 , 30 )  " AGE IS ".
                DISPLAY ( 17 , 30 )BYY " YEARS " BMM " MONTHS " BDD " DAYS ".
                STOP RUN.

  
Share: 


Didn't find what you were looking for? Find more on Program of date manipulation Or get search suggestion and latest updates.

Kuhlbert Schmidt
Kuhlbert Schmidt author of Program of date manipulation is from Frankfurt, Germany.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!