Hi
I created DATE, TIME and TIMESTAMP fields in a physical file. But I donot know how to populate the values to these fields from a COBOL program. When I include the file in a cobol program, the date field comes as FILLER PIC X(10), the tome field comes as FILLER PIC X(8) and the timestamp field comes as FILLER PIC X(26). I can receive values from the system for date and time and populate them to these fields. Is it the way to populate DATE and TIME fields in COBOL?
And as for the TIMESTAMP I do not know how to poplulate values this way also. Please suggect.
Software/Hardware used:
ASKED:
November 7, 2005 7:22 AM
UPDATED:
November 9, 2005 1:36 AM
The CRTBNDCBL or CRTCBLMOD command has a conversion parameter for handling date, time, and timestamp fields from the database. Try adding ‘CVTOPT(*DATETIME *DATE *TIMESTAMP)’ to your compile. This will bring the fields in as ‘FORMAT DATE’, ‘FORMAT TIME’, and ‘FORMAT TIMESTAMP’.
To populate a date field I use the intrinsic CURRENT DATE function — e.g., move current date to Today. ‘Today’ is defined in working storage as ’01 Today format date ‘@Y%m@d’. Then I can move to a date in any other format and the system takes care of conversion for me. e.g., If you want a date in *USA format, define in working-storage:
01 USA-date format date ‘%m/%d/@Y’.
then in the procedure division:
move Today to USA-date.
Hi,
You can accept date and time and then STRING these fields into a PIC X(26) field in the format CCYY-MM-DD.HH.MM.SS.MS0000′ then move this to a TIMESTAMP field.
However, SQL has superior date and time functions. Rather try them.
I have a problem for everone:
I am trying to do SOCKETS in COBOL and have trouble accessing the ‘errno’ field from the SOCKETS functions. I have declared errno and extern and bound the sockets functions but still do not get a value in errno.
Any help will be appreciated.