|
See if this helps your solution:
D DTEOFHIRE S D
The "10" is not needed. A date field knows what it is.
Then:
C eval DTEOFHIRE = %date(%char(X)
+ %char(EmpDay2)
+ %char(EmpCentury): *mdy0)
That should do it. Then you can forget about the data structure.
On 1/5/2015 8:34 PM, Gary Kuznitz wrote:
Thanks Paul,execute
I found a number of issues with my code.
I changed the DS to this:
D Empdate2 10A
D EmpDay2 2 0 Overlay(Empdate2:1)
D 1 INZ('/') Overlay(Empdate2:3)
D EmpMonth2 2 0 Overlay(Empdate2:4)
D 1 INZ('/') Overlay(Empdate2:6)
D EmpCentury 2 0 INZ(20) Overlay(Empdate2:7)
D EmpYear2 2 0 Overlay(Empdate2:9)
D DTEOFHIRE S 10D INZ DatFmt(*USA)
I changed the calcs to this:
C Eval EmpDay2 = EmpDay
C Eval EmpYear2 = EmpYear
C Eval EmpMonth2 = X
C Eval DTEOFHIRE = %Date(Empdate2:*USA)
When I debug it I get this:
DTEOFHIRE = '01/01/0001'
EMPDATE2 = '15/01/2001'
When it tries to do the last Eval I get this:
Date, Time or Timestamp value is not valid
Thanks,
Gary
On 5 Jan 2015 at 20:46, paultherrien@xxxxxxxxxxxxxxxxxx (
<rpg400-l@xxxxxxxxxxxx>) commented about RE: Converting a date:
There are some issues in your code.
DTEOFHIRE Is a subfield of what data structure?...
D DTEOFHIRE 10D INZ DatFmt(*USA)
Do you get the error on the compile or on execution of the program?
Is the value of the date field Empdate2 'mm/dd/ccyy'?
Based on your snippets of code I was able to compile a program and
format.with an initialized value in Empdate2 of '11/12/2014'.
I had to make DTEOFHIRE a stand-alone field in order to compile it.
D DTEOFHIRE _S_ 10D INZ DatFmt(*USA)
So that appears to work. I am on V7R1.
Paul
-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Gary
Kuznitz
Sent: Monday, January 05, 2015 8:18 PM
To: RPG programming on the IBM i (AS/400 and iSeries)
Subject: Converting a date
I can't seem to figure out how to reformat a date to get it in *USA
Empdate2
The error I'm getting is:
*RNF7606 20 2000004 The Data-Format entry is A or N but field
DTEOFHIRE is
not of type character or indicator.
D DTEOFHIRE 10D INZ DatFmt(*USA)
O DTEOFHIRE
DDS:
A DTEOFHIRE L TEXT('Employment Date')
A COLHDG('Employment' +
A 'Date' )
I'm running this on V5R3.
It could easily be I haven't loaded DTEOFHIRE correctly.
I read in Emplydate. EmpMonth is a 3 char Month Jan, Feb
D DS
D Emplydate
D EmpDay 2 0 Overlay(Emplydate:1)
D EmpMonth 3 Overlay(Emplydate:4)
D EmpYear 2 0 Overlay(Emplydate:8)
D DS
D Empdate2 10A
D EmpCentury 2 0 INZ(20)
D EmpYear2 2 0 Overlay(Empdate2:3)
D EmpMonth2 2 Overlay(Empdate2:6)
D EmpDay2 2 0 Overlay(Empdate2:9)
I do a lookup on a table to get the month
C Z-ADD 1 X 2 0
C EmpMonth LookUp Months(X) 31
C Move Empdate2 DTEOFHIRE
I have tried many different approaches including adding slashes to
wrongand changing Empdate2 from *Char. I don't know what I must be doing
--even though there must be 20 different ways this can be done.
Thanks,
Gary
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.
Booth Martin<br>
www.martinvt.com<br>
(802)461-5349<br>
Skype: booth.martin<br><br>
Adversity makes men, prosperity monsters.
-- French Proverb
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.