Date in comp-3 Format and conversion.

OS/VS COBOL, COBOL II, Enterprise COBOL for z/OS. OpenCOBOL and OOCobol.
Post Reply
Manoj
Registered Member
Posts: 33
Joined: Wed Jul 17, 2013 9:10 am

Date in comp-3 Format and conversion.

Post by Manoj »

I have a date stored in a COMP-3 field in YYYYMMDD format. I need to check the Year. Is there some easy way to find the year? Please help.
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1891
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: Date in comp-3 Format and conversion.

Post by Robert Sample »

Define a 4-byte numeric variable. Compute that variable = date-variable / 10000. Since COBOL will perform integer arithmetic, you'll get the MMDD removed and just the year as the result.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM COBOL, GnuCOBOL (OpenCOBOL), OOCobol.”