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????
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.
Joined: 14 Jan 2008 Posts: 2504 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'.