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


  • Subject: Re: "extract" command enhancement
  • From: dhandy@xxxxxxxxxxx (Douglas Handy)
  • Date: Thu, 16 Sep 1999 11:20:41 -0400

Rick,

>It would be nice to be able to extract only the century  with the "extract"
>command. Right now you can only extract the 2 digit or 4 digit year. I do it 
>now
>with a data structure.

Why not just code a subprocedure to return the value?  By making the
argument a date field and specify Const, you can pass any format date
field (ISO, USA, EUR, MDY, JUL, etc) and the routine will see it as
the format coded in the subprocedure.  Then do the DS thing and pass
back the century. 

This gives you the ability to use it in expressions now, without
waiting for Hans & Co to add new BIFs.  I use a service program for
all my date handling routines, including extracting the day or month
or year or whatever.

New BIFs are nice, but some of this stuff can be coded even on V3R2.  

Here is a sample, without using a service program:

     H Option(*SrcStmt: *NoDebugIO)

     D MdyDate         S               D   DatFmt(*MDY)
     D                                     Inz(D'2000-02-29')
     D X               S              2S 0

     D GetCentury      PR             2S 0
     D  InpDate                        D   Const DatFmt(*ISO)

     C                   Eval      X = GetCentury( MdyDate )
     C     X             Dsply                   x
     C                   Eval      *InLR = *On
      * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     P GetCentury      B
     D GetCentury      PI             2S 0
     D  Input                          D   Const DatFmt(*ISO)

     D                 DS
     D IsoDate                         D   DatFmt(*ISO)
     D  Century                       2S 0 Overlay(IsoDate:1)

     C                   Eval      IsoDate = Input
     C                   Return    Century

     P GetCentury      E
      * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+---
| 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 ...

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.