Logo 
Search:

Cobol Articles

Submit Article
Home » Articles » Cobol » Homework HelpRSS Feeds

PROGRAM FOR GENERATING DATE AND TIME

Posted By: Raymund Fischer     Category: Cobol     Views: 9064

WRITE A PROGRAM FOR GENERATING DATE AND TIME.

Code for PROGRAM FOR GENERATING DATE AND TIME in Cobol

      IDENTIFICATION DIVISION.
       PROGRAM-ID.dat.

      ENVIRONMENT DIVISION.
       SOURCE-COMPUTER. IBM-PC.
       OBJECT-COMPUTER. IBM-PC.

      DATA DIVISION.
       WORKING-STORAGE SECTION.
        01 cr-date1.
        05 yr pic 99.
        05 FILLER PIC X VALUE "/". 
        05 mnth pic 99.
        05 FILLER PIC X VALUE "/".
        05 date1 pic 99 value 10.

        01 cr-date2.
        05 yr1 pic 99.
        05 mnth1 pic 99.
        05 date11 pic 99 value 10.

     77 jul-dy pic 9(6). 
        01 tm.
         05 hh1 pic 99.
         05 mm1 pic 9.
         05 ss1 pic 99.
         05 fs1 pic 9.
        01 tm1 pic 9(10).
        77 dy-of-wk pic 9.


      PROCEDURE DIVISION.
         ACCEPT cr-date2 FROM DATE.
         MOVE yr1 TO yr.
         MOVE mnth1 TO mnth.
         MOVE date11 TO date1.
         
     
          DISPLAY cr-date1.
          DISPLAY "YEAR:" yr.
          DISPLAY "month:" mnth.
          DISPLAY "date:" date1.

          DISPLAY cr-date2.
          DISPLAY "YEAR:" yr1.
          DISPLAY "month:" mnth1.
          DISPLAY "date:" date11.

       ACCEPT jul-dy FROM DAY.        
         
       ACCEPT tm FROM TIME.
         ACCEPT tm1 FROM TIME.
         ACCEPT dy-of-wk FROM DAY-OF-WEEK.
         
       DISPLAY "julian" jul-dy.
         DISPLAY "time" tm.
         DISPLAY "HH" hh1.
         DISPLAY "MM" mm1.
         DISPLAY "SS" ss1.
         DISPLAY "TM1" tm1.
         DISPLAY " day of week" dy-of-wk.
  
         STOP RUN.
         

*******
OUTPUT:
*******

04/12/16
year :04
month:12
date :16
041216
YEAR :04
month:12
date :16
julian004351
time125858
HH12
MM5
SS85
TM10012585835
day of week 4


  
Share: 


Didn't find what you were looking for? Find more on PROGRAM FOR GENERATING DATE AND TIME Or get search suggestion and latest updates.

Raymund Fischer
Raymund Fischer author of PROGRAM FOR GENERATING DATE AND TIME 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!