× 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: last day of month (was MIDRANGE-L Digest V2 #1546)
  • From: Jim Langston <jlangston@xxxxxxxxxxxxxxxx>
  • Date: Mon, 18 Oct 1999 08:09:00 -0700
  • Organization: Conex Global Logistics Services, Inc.

Coming from various languages, I have learned never to trust the
initialized value of any variable.  I understand that this shouldn't be a
problem on the AS/400, but are we guaranteed that all variables will
be initialized to 0 (or their respective *lowval's?)

I find depending on an initialized value makes code very difficult to
understand an maintain.  I would just as well take the 2 nanosecond "hit"
and do an Eval   Isodd = 01     just to make my code crystal clear.

Regards,

Jim Langston

bmorris@ca.ibm.com wrote:

> >Date: Thu, 14 Oct 1999 09:16:48 -0700
> >From: Jon Erickson <jerickson@800.com>
> >
> >Correct me if I'm wrong,
> > ...
> >
> >d                 DS
> >d Isodate                         d   Inz
> >d  Isoyyyy                       4  0 Overlay(Isodate)
> >d  Isomm                         2  0 Overlay(Isodate:6)
> >
> >c                   Eval      Isoyyyy = Pyear
> >c                   Eval      Isomm = Pmonth
> >Add 1 month via ADDDUR
> >c                   AddDur    1:*Months     Isodate
> >
> >Subtract 1 day via SUBDUR
> >c                   SubDur    1:*Days       Isodate
>
> Sure, that will work.  I was discussing Jon's code to solve the general case 
>of
> getting the last day of the month containing a given date.
>
> Jon's code can be made to run a bit more quickly using overlays (you can get 
>rid
> of the extract by just setting the days part to "01").  Maybe that's a good
> idea,
> maybe not - it seems to me that using overlays makes the code a bit more
> complex.
>
> If you start with numeric year and month as in your example, your way is as 
>good
> as any.
>
> Hmm, I just thought of a way to use numeric year and month input avoiding
> overlays, with a single adddur:
>
> D date            s               d       datfmt(*iso) inz(D'0001-01-31')
>  * Find the number of months after 0001-01 for the given year and month
>  * E.g. for 0002-03, there are 12 + 1 months
> C                   eval      Pmonth = ((Pyear - 1) * 12) + (Pmonth - 1)
>  * Add them to Jan 31, 0001.  Month-end adjustment will fix up any results
>  * where the number of days in the month is less than 31.
> C                   adddur    Pmonth:*m     date
>
> With date operations, the contest should be regarding the number of date
> opcodes,
> not the number of statements.  (Date opcodes are very expensive.)
>
> Barbara Morris
>
> +---
> | This is the Midrange System Mailing List!
> | To submit a new message, send your mail to MIDRANGE-L@midrange.com.
> | To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com.
> | To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com.
> | Questions should be directed to the list owner/operator: david@midrange.com
> +---

+---
| This is the Midrange System Mailing List!
| To submit a new message, send your mail to MIDRANGE-L@midrange.com.
| To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com.
| To unsubscribe from this list send email to MIDRANGE-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-Ups:
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.