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



hi TA,

I wonder if you are confusing two different things? There are two date related things you might be referring to...

1. The *DATE special field. This is a numeric field, provided by the RPG compiler, that always contains the job date. You might refer to this as "the *DATE field".

2. The date variable type. When you create a variable, you assign it a data type (A=Alpha, P=Packed, S=Zoned, etc) and there's a D=Date data type you can use. You might refer to a field defined this was as "a date field" (notice that I did _not_ say "a *date field")


Anyway, based on your text, I'm wondering if you're confusing the two things. Edit codes (such as Y) are only for numeric values -- so they will indeed work with *DATE, which is numeric. So if the reference manual says that Y works with *DATE, it's absolutely correct. (*DATE is _not_ a date field, it's a numeric field.)

If you want to format a date (data type) field, then it's easy enough to do... For example, you could do this:

myCharField = %char(myDateField:*USA)
// result = 08/02/2011

Or if you want to remove leading zeroes you could trim them:

myCharField = %triml(%char(myDateField:*USA):'0');
// result = 8/02/2011 or 10/02/2011

If you want to remove leading zeroes from any of the components of the date, you'd have to do it yourself (more or less) but it's not hard.

myCharField = %char(%subdt(myDateField:*MONTHS)) + '/'
+ %char(%subdt(myDateField:*DAYS)) + '/'
+ %char(%subdt(myDateField:*YEARS));

These examples are all in the USA format (MM/DD/YYYY), but they don't have to be... you can replace *USA with other formats, applicable to different environments.

Does this help, or am I barking up the wrong tree?

On 8/2/2011 4:32 PM, Timothy Adair wrote:
In the printer output specs of my program, I am attempting to suppress the
leading zero on a *DATE field. According to the RPG ILE manual (v6r1) I
should be able to do this with a "Y" edit code.

Unfortunately, the RPG compiler gives *RNF7059 (Editing is not valid with a
field that is not numeric; the Edit Code or Edit Word defaults to blanks).

Am I missing something obvious?

~TA~



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.