Page 1 of 1

converting a 4-byte PD value to a DB2 time format

PostPosted: Thu Dec 16, 2010 6:47 am
by ricklennox
Hi, I have an input record which contains a 4-byte PD date field (X'0yymmddC'), followed by a 4-byte PD time field (X'hhmmsssC'). I'm trying to convert both fields into their DB2 formatted counterparts using the BUILD command.

I'm able to convert the PD date value to the desired DB2 date format (CCYY-MM-DD) using the following :
OUTFIL BUILD=(1:1,4,Y2V,TOGREG=Y4T(-)) ..
but I've been searching for a method of converting the PD time value to the DB2 time format (HH.MM.SS).

Part of the problem here is that the time value recorded in the PD field includes the tenths of a second. My attempts at converting it using :
OUTFILE BUILD=(1:1,4,Y2V,TOGREG=Y4T(-),11:5,4,PD,EDIT=(TT.TT.TT)) isn't working. The additional tenth of a second forces the edit to truncate the high-order HH value.. Ex. X'1234567C' becomes '23.45.67'.

I'd like to avoid reformatting the input via an INREC, if possible, but any suggestions would be greatly appreciated.
Thanks,
Rick.

Re: converting a 4-byte PD value to a DB2 time format

PostPosted: Thu Dec 16, 2010 7:14 am
by Frank Yaeger
Divide the PD time value by 10 before editing it.

11:5,4,PD,DIV,+10,EDIT=(TT.TT.TT)

Re: converting a 4-byte PD value to a DB2 time format

PostPosted: Thu Dec 16, 2010 8:26 am
by ricklennox
simple, elegant, and effective... like the infamous 'black mini-dress'! :D
thank you very much, sir