Oops typo
w@DateStart was 2 months ahead, not one, and W@dateEnd Should be based
on W@DateStart, but im sure you get my drift. Ill repost...
W@DateStart = ((w@Date - %DAYS(%SUBDT(w@Date:*D)) ) + %DAYS(1) ) +
%MONTHS(1);
W@DateEnd = ( W@DateStart + %MONTHS(1) ) - %DAYS(1);
Martin
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[
mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Hillier, Martin
Sent: 19 June 2007 15:10
To: RPG programming on the AS400 / iSeries
Subject: RE: Last day of the next month
Hi Derek
Add one month to the first day of next month (In your code below), then
subtract 1 day.
Assuming w@date is setup, The below Code could also be replaced by
something like:
W@DateStart = ((w@Date - %DAYS(%SUBDT(w@Date:*D)) ) + %DAYS(1) ) +
%MONTHS(2);
W@DateEnd = ( W@Date + %MONTHS(1) ) - %DAYS(1);
Cheers,
Martin
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[
mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of derek gonsalves
Sent: 19 June 2007 14:43
To: RPG400-L@xxxxxxxxxxxx
Subject: Last day of the next month
Hi everyone,
What would be the simplest way to find the last day of the next month?
I have a requirement, wherein i need to update a particular field with
the first day of the next month and another field with the last day of
the next month.
I have done this using the following -
@CDate Ds
@CC 1 1 0
@CY 2 3 0
@Str51 4 4 Inz('/')
@CM 5 6 0
@Str52 7 7 Inz('/')
@CD 8 9 0
dW@dat s d
*CYMD Movel @CDate W@dat
AddDur 1:*M W@dat
*CYMD Movel W@dat @CDate
Eval cent = @CC
Eval year = @CY
Eval mont = @CM
Eval day = 01
Now this handles the first day of the next month, How will i handle the
last day of the next month. Any suggestions?
Thanks in advance
Derek
As an Amazon Associate we earn from qualifying purchases.