Code for Program to check entered date is valid birth date or not 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.