IBM Support

Converting a Julian Date to MMDDYY Format Using SQL using Query for i

Troubleshooting


Problem

This document describes a method that can be used to convert a five-digit numeric field in the format of YYDDD into a date data type with Query for i (Query/400).

Resolving The Problem

Following is a method that can be used to convert a five-digit numeric field with Julian Date data in the form YYDDD into a field with a date data type using Query for i:

SELECT   DATE('19'||DIGITS(yyddd)) from library/file

To have the results returned in a certain date format, add the CHAR function. If the format of the current job is desired, typically MMDDYY, use the following:

SELECT   CHAR(DATE('19'||DIGITS(yyddd))) from library/file

This example is for 19xx year dates.  Append a 20 instead of a 19 for 20xx year dates.

[{"Type":"MASTER","Line of Business":{"code":"LOB68","label":"Power HW"},"Business Unit":{"code":"BU070","label":"IBM Infrastructure"},"Product":{"code":"SWG60","label":"IBM i"},"ARM Category":[{"code":"a8m0z0000000CQbAAM","label":"IBM i Db2-\u003EQuery\/400"}],"ARM Case Number":"","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"All Versions"}]

Historical Number

29901454

Document Information

More support for:
IBM i

Component:
IBM i Db2->Query/400

Software version:
All Versions

Operating system(s):
IBM i

Document number:
639891

Modified date:
29 November 2024

UID

nas8N1016596

Manage My Notification Subscriptions