× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Are you doing a USA date or a European date?
Your data structure shows Day first, then Month. Should it not be Month
then day?

Regardless, when you are using the %date function you really want to give it
a numeric value.
In your example EmpDate2 should have a value like mmddyyyy

Ex:
Eval Empdate = 09012014
Eval DTEOFHIRE = %Date(Empdate2:*USA)

Will get you a date of 09/12/2014 in DTEOFHIRE.


Paul Therrien
Andeco Software, LLC
225-229-2491
paultherrien@xxxxxxxxxxxxxxxxxx
www.andecosoftware.com


-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Gary
Kuznitz
Sent: Monday, January 05, 2015 9:34 PM
To: RPG programming on the IBM i AAS/400 and iSeries"
Subject: Re: Converting a date

Thanks Paul,

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
execute 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
format.

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
Empdate2 and changing Empdate2 from *Char. I don't know what I must
be doing wrong 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.



--
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 thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.