Page 1 of 1

Geeting Current Date in a COBOL program.

Posted: Mon Sep 21, 2015 12:37 pm
by Shahid
Hello,

To get the current-date from system date and to display it, I am using below code:

Code: Select all

PROCEDURE DIVISION. 
01-DATE-PARA.            
    ACCEPT WS-DATE FROM DATE.        
    DISPLAY 'THE DATE: ' WS-DATE. 
 
It displays the date as "150921" but I want it to be displyed like: "20150921". What change do I need to get it? Please help.

Thanks.

Re: Geeting Current Date in a COBOL program.

Posted: Mon Sep 21, 2015 1:46 pm
by zprogrammer
Quoting the syntax from Enterprise cobol manual

Code: Select all

   ___ Format 2: system information transfer ________________________________________________________  
  |                                                                                                  |
  | >>__ACCEPT__identifier-2__FROM__ _DATE__ __________ _ ________________________________________>< | 
  |                                 |       |_YYYYMMDD_| |                                           | 
  |                                 |_DAY__ _________ ___|                                           | 
  |                                 |      |_YYYYDDD_|   |                                           | 
  |                                 |_DAY-OF-WEEK________|                                           | 
  |                                 |_TIME_______________|                                           | 
  |                                                                                                  |
  |__________________________________________________________________________________________________|
 


Re: Geeting Current Date in a COBOL program.

Posted: Mon Sep 21, 2015 3:17 pm
by William Collins
There is also an intrinsic function, CURRENT-DATE, which you may want to look at, which has more extensive information than is returned by ACCEPT DATE YYYYMMDD.

Re: Geeting Current Date in a COBOL program.

Posted: Tue Dec 15, 2015 10:03 pm
by Shahid
Thanks both. I have made use of CURRENT-DATE.