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



On Thu, 10 Jan 2002 THarteau@felkerbrothers.com wrote:
>
>      This may sound like a silly question, but how do you get today's date
> into a date field? I can do almost anything in RPG 400 or 3, but I'm still
> learning RPG 4. In the past I have moved UDATE to a 6.0 field, added that
> and 20000000 to an 8 digit field, then moved that to the date field. There
> has got to be an more elegant way to do this, isn't there? Thanks!
>

Hi.

    First of all, even in RPG/400 I wouldn't do it this way!  You
don't want the leading "20" to be hardcoded...  In RPG/400, I would
use *DATE instead of UDATE, because it fills in all 8 digits.

The same exact method is available in RPG IV.  You can move *DATE or
UDATE in exactly the same way.

Likewise, if you didn't want the job date  (which is what UDATE and *DATE
give you -- the date the user signed on or the job was submitted) then
you would use the TIME op-code in RPG/400.   The same TIME op-code is
available in RPG IV, and you use it the same way.

RPG IV also has other ways of doing things that RPG III did not.   You
can use date-type fields, and initialize them from UDATE or TIME.  You
can also have the system initialize the date fields for you at start-up.

      ** Example:   Populating a numeric var with UDATE
     C                   move      UDATE         my_date           6 0

      ** Example:   Populating a numeric var with *DATE
     C                   move      *DATE         my_date           8 0

      ** Example:   Populating a numeric date with TIME
     C                   TIME                    temp             14 0
     c                   move      temp          my_date           8 0

      ** Example:   Populating a date field with UDATE
     D my_date         S               D
     C     *jobrun       move      UDATE         my_date

      ** Example:   Populating a date field with TIME
     D my_date         S               D
     C                   time                    my_date

      ** Example:   Populating a date field at program initialization
      **            (using system clock)
     D my_date         S               D   inz(*SYS)

      ** Example:   Populating a date field at program initialization
      **            (using job date)
     D my_date         S               D   inz(*JOB)





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.