Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Validate a date field in ILE-RPG

1,455 views
Skip to first unread message

Oesi

unread,
Nov 29, 2001, 5:40:10 AM11/29/01
to
Hi everybody,

I just want to check a date (format ddmmyy) in ILE RPG but I don't know
what's wrong with these lines...

D DateIn S D datfmt(*dmy)
C test (e) DateIn
C if %error
C exsr $errormsg
C endif

The input date is for example 241000 and I always get an error. Can
anybody help me, because I'm very new in programming with ILE-RPG.


Thanks


Bernd

elb...@cmfurniture.com

unread,
Nov 29, 2001, 8:11:53 AM11/29/01
to
A field of type date can not contain an invalid date. You get an error
as you noticed.

You need to input the value to either a numeric or character field.
Then test the value to see if its a valid date. If its valid you may
then move it to a date type field.


On Thu, 29 Nov 2001 11:40:10 +0100, Oesi <bernd.oe...@uni.de>
wrote:

Brooks Roach

unread,
Nov 29, 2001, 10:19:26 PM11/29/01
to
Bernd... Try:
If your entry is 241000 then it's a number, right? '24/10/01' would be
a date field. If you redefine your DateIn to be six numeric, you can
then change your code to:
C *DMY test (de) DateIn 28

Your source editor will tell you which position to place the indicator in.
Good luck,
Brooks

David Scorca

unread,
Nov 30, 2001, 3:06:34 AM11/30/01
to
Let me first say that the biggest confusion with date fields is that
RPG programmers (like myself) are not used to them. A field that is
mmddyy format is not a date field, it is a numeric field. '24/10/00'
is a date field.

Think of a date field as a character field which you are allowed to do
date type functions such as adding a duration, calculating a duration,
and comparing dates as dates regardless of the date fields format. In
other words, you can compare a DD/MM/YY date field with a MM/DD/YY
date field and get the results you would expect.

Now, the beauty of the TEST op-code is that you can use it to test a
numeric field to check if it contains a valid date. However, when you
are testing a numeric field for a valid date value you have to tell
the system (in factor 1) what format the numeric field represents.
When testing a truely defined date field you don't have to tell the
system the format because it already knows what format the date should
be in.

David Scorca
Computer Solutions, Inc.
305 558-7000 x131

On Thu, 29 Nov 2001 11:40:10 +0100, Oesi <bernd.oe...@uni.de>
wrote:

>Hi everybody,

Francis Lapeyre

unread,
Dec 1, 2001, 12:24:25 PM12/1/01
to
Date fields (defined as type 'D' are always going to be "valid". The purpose of TEST(DE) with the date format in Factor 1 is to test dates in numeric or character fields for validity so they can be moved to a date field.

Are you testing to see if the field contains a date at all? Then compare it to the low value in that date format:

C If Date > D'01/01/01'
C .........(valid)
C Else
C ..........(invalid)
C Endif

If the date in question is a null capable field, test for %NULLIND(date) being *ON or *OFF. If it's *ON, there is no date in there.

--

Regards,
Francis Lapeyre

"Facilius est camelum per foramen acus transire quam divitem intrare in regnum Dei."
(Mk 10:25)

Return address is filtered via SpamCop.

"Oesi" <bernd.oe...@uni.de> wrote in message news:3C06108A...@uni.de...

Psoriano

unread,
Dec 3, 2001, 11:23:30 AM12/3/01
to
It's TEST(D) and not TEST(E).
Philippe

"Oesi" <bernd.oe...@uni.de> a écrit dans le message news:
3C06108A...@uni.de...

Stefano

unread,
Dec 4, 2001, 9:46:58 AM12/4/01
to
Oesi <bernd.oe...@uni.de> wrote in message news:<3C06108A...@uni.de>...
> Hi everybody,
Hi :o)

> I just want to check a date (format ddmmyy) in ILE RPG but I don't know
> what's wrong with these lines...

[cut]

> Can anybody help me, because I'm very new in programming with ILE-RPG.

Try to read this:
"RPG IV Date Support"
http://www.rpgiv.com/seminars/datetime.pdf

> Thanks
> Bernd
I hope it may help you to bettr understand the way date data type are used...

Stefano

"Niuna impresa, per minima che sia
può avere cominciamento e fine senza queste tre cose:
e cioè senza sapere, senza potere, senza con amore volere"
[Anonimo fiorentino, XIV sec.]

0 new messages