How to get the unload result in Packed decimal format if the table column is in INTEGER formmat in the DB2 table?

StackOverflow https://stackoverflow.com/questions/7820890

  •  27-10-2019
  •  | 
  •  

Question

I have a one query explaind below....,

1.My DB2 table column is in INTEGER format (it has the date value in Julian date format - YYYYDDD)

2. After unload this date into a flat file, the result is in hexa decimal format.(4 bytes occupaid)

3. I have a requirement to compare this date with (Current Julian date+7days) and write the corresponding recods into a File. 

4. So, when I am comparing the Hexa decimal Input date with Current Julian date+7days (DATE3P+7), I am getting MAxcc=0 but I am not getting required output. 

5. What I identified the problem is that the input date should also be in packed decimal format. 

Can anybody please let me know how to convert the table value in Packed decimal while unloading or please suggest alternate way to get it.

Ex:- 1. Unload Julian date (YYYYDDD) [After unload this will be in hexa decimal format]. 2. compare with Current Julian date +7 days. SORT FIELDS=COPY OUTFIL FILES=1, INCLUDE=(1,4,PD,LT,DATE3P+7) OUTFIL FILES=2,SAVE

Thanks in Advance, Rajasekhar Jannu.

Was it helpful?

Solution

Believe these alternate ways, work...

  • Instead of getting the date in hex type, unload it as date in YYYYDDD format and the DATE3 will give you the julian date in YYYYDDD. Now these both are in compatible format to compare and condition.

    There are many scalar functions of DB2 to provide Julian date and as well date in numbers. I believe DIGITS on JULIAN scalar function would do...

    Refer this DB2 Scalar Functions

  • If you couldnt unload the table in the way described above, another way would be manipulating the unload file, so that date from hex format needs to be converted into YYYYDDD numeric format using DFSORT. Then DATE3 will help u to get one week old data. DFSORT reference has been already shared.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top