I am taking a date variable in database in YYYY-MM-DD:hh:min:ss format and i want to display it in report YYYY-MM-DD HH:MIN:SS using cobol program.How to do this?
Take a look at Intrinsic Functions, for example
http://opencobol.add1tocobol.com/#does-opencobol-implement-any-intrinsic-functions
To get the current clock, look to ACCEPT FROM DATE YYYYMMDD, ACCEPT FROM TIME
Then you may want to create a PICTURE data clause, giving you absolute control over how your dates and times are formatted and displayed.
I've also found INSPECT REPLACING to be a handy thing when you want to quickly convert colons to spaces, or slashes etc.
identification division.
program-id. inspecting.
data division.
working-storage section.
01 ORIGINAL pic XXXX/XX/XXBXX/XX/XXXXXXX/XX.
01 DATEREC pic XXXX/XX/XXBXX/XX/XXXXXXX/XX.
procedure division.
move function when-compiled to DATEREC ORIGINAL
INSPECT DATEREC REPLACING ALL "/" BY ":" AFTER INITIAL SPACE
display
"Intrinsic function WHEN-COMPILED " ORIGINAL
end-display
display
" after INSPECT REPLACING " DATEREC
end-display
goback.
end program inspecting.
giving
Intrinsic function WHEN-COMPILED 2010/03/25 23/05/0900-04/00
after INSPECT REPLACING 2010/03/25 23:05:0900-04:00