• Subject: RE: Dates
  • From: Larry Paque <larry@xxxxxxxxxx>
  • Date: Fri, 19 Nov 1999 16:27:22 -0800

This is the easiest way to convert a YMD numeric date to a date field.  IBM
assumes years 00-39 are 2000-2039, 40-99 are 1940-1999.
Of course, depending on your data source you can skip the TEST(D).
For comparisons we just code a date constant.

D RealDate   S        D
D YMDDate    S       6S 0
D ConstDate  C        D       CONST('1999-12-31') 

C     *YMD      TEST(D)  YMDDate                 90 (error col) 
C               IF       *IN90
C               CLEAR               RealDate
C               ELSE
C     *YMD      MOVE     YMDDate    RealDate
C               ENDIF
C                 IF       RealDate > ConstDate


-----Original Message-----
From: Jim Langston [mailto:jlangston@conexfreight.com]
Sent: Friday, November 19, 1999 3:17 PM
To: RPG400-L@midrange.com
Subject: Dates


I have a file with dates stored in a numeric MMDDYY format.  I convert
them to dates using the following:

D                             DS
D RealDate                1  10D        DATFMT(*ISO)
D  RealDateCC         1    2S 0
D  RealDateYY         3    4S 0
D  RealDateMM        6   7S 0
D  RealDateDD          9 10S 0
D YMDDate             11 16S 0
D   YMDDateYY      11 12S 0
D MDYDate             13 18S 0
D   MDYDateYY      17 18S 0
D DateMM                13 14S 0
D DateDD                  15 16S 0

C          Eval  MDYDate = FEDEta
C          Exsr  MDYDateToDate

the Sub MDYDateToDate just does a bunch of moving around of values,
comparing
MDYDateYY to 99, if it's 99 it sets RealDateCC to 19, otherwise sets to
20, then
it moves the YY MM and DD fields to the Date field, then I have a date
fields.

Is there an easier way?  There MUST be!

Also, later on I attempted to do a comparison,

C              If      RealDate < '1999-11-01'

but received an error, incompatable types.  so I then copied the
RealDate to
a date varialbe, and did the whole rigamarole in converting 110199 to
RealDate,
then could do the comparison between dates.

Again, there MUST be an easier way!

How do you hard code a date so that RPG recognizes it as a date?

Any help would be appreciated,

Regards,

Jim Langston


+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator:
david@midrange.com
+---
+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---


As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.