DATE, TIME and TIMESTAMP fields in the database files

20 pts.
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.

Answer Wiki

Thanks. We'll let you know when a new response is added.

do the work with sql, it natively support these kind of fields.

steps :
-1- try the sql orders with STRSQL
-2- embbed sql in your code.

if necessary, doc is in “DB2 UDB for iSeries SQL Programming with Host Languages” or “DB2 Universal Database for iSeries SQL Reference”, IBM books

Discuss This Question: 2  Replies

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • TheQuigs
    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.
    0 pointsBadges:
  • JohnDavid
    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.
    5 pointsBadges:

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.


Share this item with your network: