View previous topic :: View next topic
|
Author |
Message |
Jeya Raj
New User
Joined: 14 Jan 2007 Posts: 33 Location: USA
|
|
|
|
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 |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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 |
|
|
|