|
Here's what I did to get the last previous Friday to any date: D DateISO s d DatFmt(*iso D DateTest s d DatFmt(*iso) INZ(D'1999-01-02') D DateAnyDay s d DatFmt(*iso) * Get last Friday: C DateAnyDay SubDur DateTest Tmp7:*D 7 0 C Tmp7 Div 7 Tmp7 C mvr Tmp7 C Eval Tmp7=tmp7+1 C DateAnyDay SubDur Tmp7:*D DateISO C Move DateISO Tmp10 10 _______________________ Booth Martin Booth@MartinVT.com http://www.MartinVT.com _______________________ "Alan Moulsdale" <alan.moulsdale@virgin.net> Sent by: owner-midrange-l@midrange.com 07/04/2000 09:42 AM Please respond to MIDRANGE-L To: <MIDRANGE-L@midrange.com> cc: Subject: Problems with CEE date APIs Hello, I am trying to write a program to calculate the last Friday of the month. I decided to use the CEE date APIs in a ILE RPG program. My problem is that the CEEDAYS API will only work if I place a DSPLY directly after it! This is obviously not desirable. I have found this to be the case at both V3R2 and V4R4. Can anybody see what I am doing wrong? Many thanks Alan Source code follows: Hdatedit(*ymd) Ddate s d datfmt(*iso) DDayNumber s 9b 0 inz DLilDate s 9b 0 inz DDateFmt s 35a inz('YYYY-MM-DD') DDateCvt s 35a Dfc s 35a D ds Dwrkdate d datfmt(*iso) D dd 2a overlay(wrkdate:9) D wrkdate2 10a overlay(wrkdate:1) /*--------------------------------------------------------------------- /* Calculation Specifications /*--------------------------------------------------------------------- * get current date C move *date wrkdate * go to first day of next month C eval dd = '01' C adddur 1:*m wrkdate * go to last day of this month C subdur 1:*d wrkdate * get day of week C callb(d) 'CEEDAYS' C parm wrkdate2 DateCvt C parm DateFmt C parm LilDate C parm fc C '>>>Help<<<' dsply C callb(d) 'CEEDYWK' C parm LilDate C parm daynumber * get last Friday of month C if daynumber < 6 C eval daynumber = daynumber + 7 C endif C if daynumber > 6 C eval daynumber = daynumber - 6 C subdur daynumber:*d wrkdate C endif * return date C 'Last Fri is' dsply wrkdate2 C eval *inlr = *on +--- | 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.