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



Correction I should have subtracted 8 Days instead of 6!!!

Mit freundlichen Grüßen / Best regards

Birgitta Hauser
Modernization ? Education ? Consulting on IBM i

IBM Champion since 2020

"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"
"Train people well enough so they can leave, treat them well enough so they
don't want to. " (Richard Branson)
"Learning is experience ? everything else is only information!" (Albert
Einstein)

-----Original Message-----
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of
Birgitta Hauser
Sent: Friday, 4 August 2023 07:32
To: 'Midrange Systems Technical Discussion' <midrange-l@xxxxxxxxxxxxxxxxxx>
Subject: RE: Getting last Friday's date

The easiest Way would be to use SQL. Then wrap it as RPG procedure and call
it from CL:

Something like this:

Exec SQL Set Option DatFmt = *ISO;

DCL-Proc PastFriday Export;
DCL-PI *N Date(*ISO);
ParStartDate Date(*ISO) Const;
End-PI;

RtnDate Date(*ISO);

If ParDate = *Loval;
Return ParDate;
EndIf;

Exec SQL Set :RtnDate = Next_Day(:ParDate - 6 Days: 'FRIDAY');
If SQLCODE < *Zeros or SQLCODE = 100;
Return *Loval;
Else
Return :RtnDate;
EndIf;

End-Proc;

Note: Procedure is not tested ... and I only subtracted 6 days. When
subtracting 7 days and the starting date is a Friday the Friday in the next
week (start date) would be returned.

Mit freundlichen Grüßen / Best regards

Birgitta Hauser
Modernization ? Education ? Consulting on IBM i

IBM Champion since 2020

"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok) "What is
worse than training your staff and losing them? Not training them and
keeping them!"
"Train people well enough so they can leave, treat them well enough so they
don't want to. " (Richard Branson) "Learning is experience ? everything else
is only information!" (Albert
Einstein)

-----Original Message-----
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Jim
Oberholtzer
Sent: Thursday, 3 August 2023 21:30
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxxxxxxxx>
Subject: Getting last Friday?s date

I need to retrieve the date from last Friday. If it is Friday, I want the
current date. Anyone have a routine that does that before I start
developing one? Seem like a good SQL problem but the program using it
would be in CLLE.

Thoughts?

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.