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



Thanks for your reply Birgitta
Isnt the way that the beginning of next month is being calculated, doing what you suggested?
Beginning_of_Next_Month = MyDate - %Days(%subdt( myDate:*days)-1) +
%months(1) ;
The piece of code
%Days(%subdt( myDate:*days)-1)
Is calculating the day of the month less one day
Subtracting that from the field mydate, then adding back one month



Alan Shore
E-mail : ASHORE@xxxxxxxx
Phone [O] : (631) 200-5019
Phone [C] : (631) 880-8640
'If you're going through hell, keep going.'
Winston Churchill


-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxxxxxxxx] On Behalf Of Birgitta Hauser
Sent: Wednesday, August 19, 2020 11:22 AM
To: 'RPG programming on IBM i' <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: [EXTERNAL] RE: problem with DAYOFWEEK_ISO in an SQLRPGLE program

Beginning of the next month is not calculated correctly.
You need to add 1 moth to the current date, then determine then day of month and subtract it from the result and add 1 day.
... but why to calculate the beginning of the next month with RPG and not SQL

Exec SQL Set :Beginning_Of_Next_Month = Last_Day(:MyDate) + 1 Day;

Or in a sigle Step:
Exec SQL Set :HoldDayOfWeek_ISO = Week_ISO(Last_Day(:MyDate) + 1 Day)

Mit freundlichen Grüßen / Best regards

Birgitta Hauser


"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)


-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Alan Shore via RPG400-L
Sent: Mittwoch, 19. August 2020 15:33
To: rpg400-l@xxxxxxxxxxxxxxxxxx
Cc: Alan Shore <ashore@xxxxxxxx>
Subject: problem with DAYOFWEEK_ISO in an SQLRPGLE program

Hi everyone
We are on V7r3
I am trying to determine the first business day of the following month I have a simple program to start of with It takes a date, calculates the first of the following month, and then finds the day of the week (ISO) The code is below (like I said - its simple) Using debug, I can see that HldDayOfWeek_ISO from DayOfWeek_ISO(Beginning_of_Next_Month) is zero (which is NOT a correct value) But HldDayOfWeek_ISO2 from
DAYOFWEEK_ISO(CURRENT_DATE) is 3 - which is correct - today being Wednesday
***NOTE*** - The value of Beginning_Of_Next_month is '2019-02-01' , according to debug Can anyone see what is wrong with this code?
Why I am not getting the DAYOFWEEK_ISO for Beginning_Of_Next_Month?
As always, all answers replies gratefully accepted

dcl-s MyDate date
inz(d'2019-01-02');
dcl-s Beginning_of_Next_Month date;
dcl-s HldDayOfWeek_ISO zoned(2:0);
dcl-s HldDayOfWeek_ISO2 zoned(2:0);

//-------------------------------------------------------------------
// Stand Alone Fields - BOTTOM
//-------------------------------------------------------------------
exec Sql Set Option Commit=*NC, CLOSQLCSR=*ENDMOD, DECMPT=*PERIOD;
exec Sql Set Option DATFMT = *ISO, NAMING = *SQL;

Beginning_of_Next_Month = MyDate - %Days(%subdt( myDate:*days)-1) +
%months(1) ;
exec sql
select DayOfWeek_ISO(Beginning_of_Next_Month)
into :HldDayOfWeek_ISO
FROM SYSIBM.SYSDUMMY1;

exec sql
SELECT DAYOFWEEK_ISO(CURRENT_DATE)
INTO :HldDayOfWeek_ISO2 FROM SYSIBM.SYSDUMMY1;

*inlr = '1';
return;

Alan Shore
E-mail : ASHORE@xxxxxxxx<mailto:ASHORE@xxxxxxxx>
Phone [O] : (631) 200-5019
Phone [C] : (631) 880-8640
'If you're going through hell, keep going.'
Winston Churchill

--
This is the RPG programming on IBM i (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related questions.

Help support midrange.com by shopping at amazon.com with our affiliate link:
https://amazon.midrange.com

--
This is the RPG programming on IBM i (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related questions.

Help support midrange.com by shopping at amazon.com with our affiliate link: https://amazon.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.