IBM Support

Example of CVTDAT Command in a CL Program

Troubleshooting


Problem

This document provides an example of a CL program that uses the CVTDAT CL command in a CL program to retrieve the system date as a 6-character field and convert it to an 8-character date.

Resolving The Problem

The following CL program is a simple example of using the CVTDAT CL command in a CL program to retrieve the system date as a 6-character field and convert it to an 8-character date.
 
Disclaimer: This is only an example. IBM accepts no responsibility for its correctness.

Example CL CVTDAT1:
             DCL        VAR(&QDATE) TYPE(*CHAR) LEN(6)
             DCL        VAR(&QDATE2) TYPE(*CHAR) LEN(10)
             DCL        VAR(&QDATE3) TYPE(*CHAR) LEN(10)

             RTVSYSVAL  SYSVAL(QDATE) RTNVAR(&QDATE)
             CVTDAT     DATE(&QDATE) TOVAR(&QDATE2)  +
                          TOFMT(*ISO) TOSEP('/')
             CVTDAT     DATE(&QDATE) TOVAR(&QDATE3) TOFMT(*YYMD) +
                          TOSEP('/')

             SNDPGMMSG  MSG('SYSTEM Value QDATE:' *bcat &QDATE)
             SNDPGMMSG  MSG('Converted to ISO:' *bcat &QDATE2)
             SNDPGMMSG  MSG('Converted to YYMD format:' *bcat &QDATE3)
             ENDPGM     
Call from command line.
> call cvtdat1                           
  SYSTEM Value QDATE: 112324             
  Converted to ISO: 2024-11-23           
  Converted to YYMD format: 2024/11/
23   

 

[{"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":"a8m3p0000006x8GAAQ","label":"CL"}],"ARM Case Number":"","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"All Versions"}]

Historical Number

19285914

Document Information

More support for:
IBM i

Component:
CL

Software version:
All Versions

Operating system(s):
IBM i

Document number:
641825

Modified date:
23 November 2024

UID

nas8N1017803

Manage My Notification Subscriptions