Move Date field to numeric field in COBOL

Tags:
Application development
Is there a function in COBOL to move a Date field to a numeric field (yyyymmdd)?

Answer Wiki

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

If I understand what you’re asking, you’ve got a date field stored YYYYMMDD and want to change to numeric, or you’ve got an SQL field, and want it as a numeric YYYYMMDD. Here are both:

First:

01 Date-record.
02 Date-field.
03 Year-part PICTURE 9999.
03 Month-part PICTURE 99.
03 Day-part PICTURE 99.
02 Numeric-version PICTURE 99999999 REDEFINES Date-part.

Second:

01 Date-record.
02 Date-field.
03 Year-part PICTURE 9999.
03 FILLER PICTURE X.
03 Month-part PICTURE 99.
03 FILLER PICTURE X.
03 Day-part PICTURE 99.
01 Other-record.
02 Date-version.
03 Year-part PICTURE 9999.
03 Month-part PICTURE 99.
03 Day-part PICTURE 99.
02 Numeric-version PICTURE 99999999.


EXEC SQL SELECT dateField INTO :Date-field FROM x WHERE y=:z.
MOVE CORRESPONDING Date-field INTO Date-version.

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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • KevinBattreall
    Let me try to explain this better. I have file XYZ. In file XYZ I have field ABC that is type DATE (format DATE). When I copy DD-ALL-FORMATS OF XYZ into my program the definition for field PIC X(10) instead of FORMAT DATE. If field ABC = '1969-03-01' and I move ABC to a numeric field (pic 9(8)). The value in the numeric field is 69000301. How do I get the copy DD-ALL-FORMATS OF XYZ to define field ABC FORMAT DATE?
    0 pointsBadges:
    report
  • KevinBattreall
    I opened a call with IBM software support. I needed CVTOPT(*DATE) in the compile options.
    0 pointsBadges:
    report

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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

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

Following