Converting ddmmyy to ccyymmdd using iSeries Query

The example below shows how to convert a six digit numeric date in DDMMYY format to an eight digit date using Query for i5/OS. Conversion takes place into CCYYMMDD and DDMMCCYY formats. Just replace example field mydate with your six digit numeric date.

A date-window concept is used to interpret the year and the field window defines the boundary. In this example the boundary is 30. This means that years between 30 and 99 are allocated a century value of 19 and years 00 to 29 are allocated century value of 20.

Important! Under processing options, make sure that round is set to “N” to prevent the divide operation from altering the month value.

 

                             Define Result Fields
                              

Type definitions using field names or constants and operators, press Enter.   
  Operators:  +, -, *, /, SUBSTR, !!, DATE...        
 
Field       Expression                         Column Heading  Len   Dec
WINDOW      30                                                          
DDMMYY      mydate                                                       
DDMM        ddmmyy/100                                           4     0
YY          ddmmyy-ddmm*100                                      2     0
DD          ddmm/100                                             2     0
MM          ddmm-dd*100                                          2     0
CCADJUST    (yy+window)/100                                      1     0
CC          20-ccadjust                                                
DDMMCCYY    dd*1000000+mm*10000+cc*100+yy
CCYYMMDD    cc*1000000+yy*10000+mm*100+dd  
 


                           Specify Processing Options               
 
Type choices, press Enter.   

  Use rounding . . . . . . . . . . .   N      Blank, Y=Yes, N=No   
Posted in tips.