|
Wouldn't all this be so much simpler if we just had the inverse of the EXTRCT opcode? Why wasn't it built at the same time as EXTRCT? -----Original Message----- From: bmorris@ca.ibm.com <bmorris@ca.ibm.com> To: MIDRANGE-L@midrange.com <MIDRANGE-L@midrange.com> Date: Friday, October 15, 1999 2:24 PM Subject: RE: last day of month (was MIDRANGE-L Digest V2 #1546) > > > >>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 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.