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



David,

Any of the 2 Year date formats only support a range of years (something
like 39-53).  When you convert the date from EndDateDS to #EndDate, you
are telling the system, with *YMD0, that the format is YYMMDD.  It will
calculate your date of 20420926 to 1942-09-26 because it ignores the
century.  You may want to use *ISO instead to handle the century.

George



>>> davidw@xxxxxxx 03/17/04 2:58 PM >>>
This is quite bizarre - we have a program that is set up to do date
durations. the code follows but here is the issue..


We send the two days (todays date and the employee retirement date in
this
case) to the program and
get back the Years and Months differences.

At the end of the program - when the actual calcs happen it looks like
this...

0121.00      * Move variables into Date defined fields
0131.00     C     *YMD0         MOVE      StrDateDS     #StrDate
0132.00     C     *YMD0         MOVE      EndDateDS     #EndDate
0133.00      *    ------------------------
0134.00      * Calculate Duration in Years
0135.00     C     #EndDate      SUBDUR    #StrDate      DurYr:*Y
0136.00      *    ------------------------
0137.00      * Calculate Duration in Months
0138.00     C     #EndDate      SUBDUR    #StrDate      DurMth:*M
0196.00      *    ------------------------
0197.00     C                   RETURN

      When we move the EndDateDS into #EndDate for any year above 2039
it
changes the
year by subtracting a century.

For example if EndDateDS = 20330926 then #EndDate = '2033-09-26'.

But if...EndDateDS = 20420926 then #EndDate = '1942-09-26'

Has anyone run into this before???  the whole code follows....
************************************



0011.00      * Work fields
0012.00     D StrDate         S              8
0013.00     D EndDate         S              8
0014.00     D DurYr           S              3  0
0015.00     D DurMth          S              3  0
0017.00     D ShutDown        S              3
0018.00     D EP#01           S              8
0019.00     D EP#02           S              8
0020.00     D EP#03           S              3  0
0021.00     D EP#04           S              3  0
0023.00     D EP#05           S              3
0024.00     D #StrDate        S               D
0025.00     D #EndDate        S               D
0037.00
*--------------------------------------------------------------
0038.00      * Data Structures
0039.00     D StrDateDS       DS
0040.00     D  StrYr                         4  0
0041.00     D  StrMth                        2  0
0042.00     D  StrDay                        2  0
0043.00     D EndDateDS       DS
0044.00     D  EndYr                         4  0
0045.00     D  EndMth                        2  0
0046.00     D  EndDay                        2  0
0047.00      * Constants
0048.00     C     SPACING       TAG
0049.00      /EJECT
0050.00
*================================================================
0051.00      * Entry Parameters
0052.00     C     *ENTRY        PLIST
0053.00     C     StrDate       PARM                    EP#01
Start Date
0054.00     C     EndDate       PARM                    EP#02
End Date
0055.00     C                   PARM      DurYr         EP#03
Dur in Years
0056.00     C                   PARM      DurMth        EP#04
Dur in Months
0057.00     C     ShutDown      PARM                    EP#05
ShutDown
0058.00      * Key Lists
0059.00      * One Time Only
0060.00
*================================================================
0061.00      * Main Line Code
0062.00
*================================================================
0063.00     C                   EVAL      DurYr = *ZEROS
0064.00     C                   EVAL      DurMth = *ZEROS
0065.00     C                   CLEAR                   #StrDate
0066.00     C                   CLEAR                   StrDateDS
0067.00     C                   CLEAR                   #EndDate
0068.00     C                   CLEAR                   EndDateDS
0069.00      *    ------------------------
0070.00     C                   IF        ShutDown = 'YES' OR ShutDown
= 'yes' OR
0071.00     C                             ShutDown = 'Yes'
0072.00     C                   EVAL      *INLR = *ON
0073.00     C                   RETURN
0074.00     C                   ENDIF
0075.00      *    ------------------------
0077.00     C                   MOVE      StrDate       StrDateDS
0078.00     C                   IF        StrDate = *BLANKS OR StrDate =
*ZEROS
0079.00     C                   RETURN
0080.00     C                   ENDIF
0081.00     C                   IF        %SUBST(StrDate:1:4) = *BLANKS
OR
0082.00     C                             %SUBST(StrDate:1:4) = *ZEROS 
OR
0083.00     C                             StrYr = *ZEROS
0084.00     C                   RETURN
0085.00     C                   ENDIF
0086.00     C                   IF        StrMth = *ZEROS
0087.00     C                   RETURN
0088.00     C                   ENDIF
0089.00     C                   IF        StrDay = *ZEROS
0090.00     C                   EVAL      StrDay = 01
0091.00     C                   ENDIF
0097.00      *    ------------------------
0098.00     C                   MOVE      EndDate       EndDateDS
0099.00     C                   IF        EndDate = *BLANKS OR EndDate =
*ZEROS
0100.00     C                   EVAL      EndYr = *YEAR
0101.00     C                   EVAL      EndMth = *MONTH
0102.00     C                   EVAL      EndDay = *DAY
0103.00     C                   MOVE      EndDateDS     EndDate
0104.00     C                   ENDIF
0105.00     C                   IF        %SUBST(EndDate:1:4) = *BLANKS
OR
0106.00     C                             %SUBST(EndDate:1:4) = *ZEROS 
OR
0107.00     C                             EndYr = *ZEROS
0108.00     C                   RETURN
0109.00     C                   ENDIF
0110.00     C                   IF        EndMth = *ZEROS
0111.00     C                   RETURN
0112.00     C                   ENDIF
0113.00     C                   IF        EndDay = *ZEROS
0114.00     C                   EVAL      EndDay = 01
0115.00     C                   ENDIF
0116.00      *    ------------------------
0117.00     C                   IF        StrYr > EndYr
0118.00     C                   RETURN
0119.00     C                   ENDIF
0120.00      *    ------------------------
0121.00      * Move variables into Date defined fields
0131.00     C     *YMD0         MOVE      StrDateDS     #StrDate
0132.00     C     *YMD0         MOVE      EndDateDS     #EndDate
0133.00      *    ------------------------
0134.00      * Calculate Duration in Years
0135.00     C     #EndDate      SUBDUR    #StrDate      DurYr:*Y
0136.00      *    ------------------------
0137.00      * Calculate Duration in Months
0138.00     C     #EndDate      SUBDUR    #StrDate      DurMth:*M
0196.00      *    ------------------------
0197.00     C                   RETURN




Dave Wolfe
Programmer/Analyst
CBInternational





_______________________________________________
This is the RPG programming on the AS400 / 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 ...


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.