Converting date for output to a display or printer in Query for iSeries

You can use the date functions to convert an input date field to a different format. Examples 1 and 2 show two methods of converting a date field from the MMDDYY format to the YYDDD format. Examples 3 and 4 show the reverse conversions, from YYDDD to MMDDYY format.

Note: For ease of reading, multiple panel views are merged into single screen images.

Example 1—Converting from MMDDYY to YYDDD format in Query for iSeries

The following Define Result Fields panel defines an MMDDYY to YYDDD date conversion. The conversion is done completely within the panel.

Define Result Fields

Type definitions using field names or constants and operators, press Enter.

Operators: +, -, *, /, SUBSTR, , DATE...

Field

Expression

Column Heading

Len Dec

YY________

SUBSTR(CHAR(MMDDYY),7,2)_________ ____________________ _____ __

 

_________________________________

____________________

 

 

_________________________________

____________________

 

CHARJAN01_

’01/01/’ YY___________________

____________________

_____ __

 

_________________________________

____________________

 

 

_________________________________

____________________

 

JAN01_____ DATE(CHARJAN01)__________________ ____________________ _____ __

 

_________________________________

____________________

 

 

_________________________________

____________________

 

DDD_______

SUBSTR(DIGITS(DAYS(MMDDYY)-DAYS(J ____________________ _____ __

 

AN01)+1),10,3)___________________

____________________

 

 

_________________________________

____________________

 

YYDDD_____ YY__’/’__DDD_________________ ____________________ _____ __

 

_________________________________

____________________

 

 

_________________________________

____________________

 

_______________________________________________________________________________

Field

Text

 

Len Dec

MMDDYY

Date field in MMDDYY format

8

L

 

 

 

Bottom

 

F3=Exit

F5=Report

F9=Insert

F11=Display names only

 

F12=Cancel

F13=Layout

F20=Reorganize

F24=More keys

 

Example 2—Converting from MMDDYY to YYDDD format in Query for iSeries

This examples shows an alternative method for the same conversion done in example 1. The conversion is done completely within the panel. This method requires that the date format for the current job must be set to YYDDD. When this circumstance exists, the DATE function automatically does the conversion.

Chapter 5. Defining result fields in Query for iSeries 81

Page 93
Image 93
IBM SC41-5210-04 manual Mmddyy