IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

COMP-3 Date field


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Jeya Raj

New User


Joined: 14 Jan 2007
Posts: 33
Location: USA

PostPosted: Tue Sep 22, 2009 11:31 pm
Reply with quote

Hi,

I need to move x(10) format date(CCYY-MM-DD) to comp-3 date field like

table-date pic x(10) CCYY-MM-DD
copy-book-date PIC S9(07) COMP-3.


I moved the table-date to temp-date which is 9(8) (to remove the - from the table-date) and then moved the temp-date to copy-book-date.

MOVE table-date TO temp-date.

MOVE temp-date TO copy-book-date.

If the table-date is 2009-09-21 and after the move the temp-date is 20090921 and the copy-book-date is as 0090921C. Please let me know how can i get 20090921 in the copy-book-date?. Do i need to store as 1090921 in the copy-book-date?. if the first digit is 1 then the century means 20????


Thank you.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Tue Sep 22, 2009 11:48 pm
Reply with quote

Since copy-book-date is defined as internal decimal, the rightmost half-byte will always be reserved for a sign (+, -, or unsigned; that is C, D, or F). If you want an unsigned result, define it as a display, unsigned numeric field, PIC 9(8). See Language Reference manual for details.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Sep 22, 2009 11:49 pm
Reply with quote

S9(07) You are telling that the field will contain 7 digits ....
how do You expect it to be able to contain 8 ...

the best thing would be to review and understand the application design

if You really need to store a date in 7 digits the forum is not really a place to ask,
somebody in Your organization must have documented the issue and the conventions to be used
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Wed Sep 23, 2009 12:04 am
Reply with quote

Would converting this Gregorian format to Julian format (CCYYDDD) be an alternative?

Julian format would fit into 4-Bytes packed-decimal, without high-order truncation.

You would need 5-bytes packed-decimal for the full CCYYMMDD value and have a high-order 4-bit X'0'.

A binary-fullword is 4-bytes (PIC S9(09) COMP) and your CCYYMMDD Gregorian formatted-date will fit, regardless of the TRUNC option, but it will be stored in HEX. For example, decimal 20090922 would be stored in the fullword as X'0132902A'.

What version/release of COBOL are you using?

Bill
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts Need help to append a date&tsp at... DFSORT/ICETOOL 9
Search our Forums:

Back to Top