STRPDM.COM                  

   Home    |    IBM Manuals Direct    |    iBytes Library   |    Links    |   About     |   Book Store   |  On-Line Code

 

iByte

Subject – Easy date manipulation

Dates can easily be formatted to the desired output with a definition specification and a move statement or two.  The examples below show the output if the incoming date was UDATE with a value of  (032901).  Dates can be moved from a numeric field to a date field and vice versa.  To convert a numeric date to a different type of numeric date two moves would be required.  First a move to a field defined as a date type and then to the resulting numeric field.  If we had a 6 digit numeric date of MMDDYY 032901 and wanted to convert it to an 8 digit numeric date of  CCYYMMDD 20010329.  We would first move the 6 digit date to an ISO format and then back to the 8 digit numeric date.  

D TodayMDY        S               D   DATFMT(*MDY) 
D TodayISO        S               D   DATFMT(*ISO) 
D TodayYMD        S               D   DATFMT(*YMD) 
D TodayUSA        S               D   DATFMT(*USA) 
D                                                  
D FileYMD         S              6  0 INZ(0)       
D FileCYMD        S              8  0 INZ(0)       

C*                  IF TODAYS DATE WAS 03/29/01 - MM/DD/YY 
C                                                          
C     *MDY          MOVE      UDATE         TodayMDY       
C*                  OUTPUT (03/29/01)                      
C                                                          
C     *MDY          MOVE      UDATE         TodayISO       
C*                  OUTPUT (2001-03-29)                    
C                                                          
C     *MDY          MOVE      UDATE         TodayYMD       
C*                  OUTPUT (01/03/29)                      
C                                                          
C     *MDY          MOVE      UDATE         TodayUSA       
C*                  OUTPUT (03/29/2001)                    

C                                                     
C     *YMD          MOVE      TodayYMD      FileYMD   
C*                  OUTPUT (010329)                   
C                                                     
C     *ISO          MOVE      TodayISO      FileCYMD  
C*                  OUTPUT (20010329)                 
C                                                     
C     *ISO          MOVE      FileCYMD      TodayISO  
C*                  OUTPUT (2001-03-29)               
C