Hi,
Added steroids....
I believe the code below will find the LAST LAST SUNDAY OF THE PRIOR MONTH" . It does not matter what day you start with in the month. This may be what you need
. I suggest testing thoroughly.
genTime('M1','Sunday less 1 weeks');
DTE1=M1DD + "-" + M1MM + "-" + M1YEAR;
if ( M1MM == APPL._SMM )
{
genTime('M2','Sunday less 2 weeks');
DTE1=M2DD + "-" + M2MM + "-" + M2YEAR;
if ( M2MM == APPL._SMM )
{
genTime('M3','Sunday less 3 weeks');
DTE1=M3DD + "-" + M3MM + "-" + M3YEAR;
if ( M3MM == APPL._SMM )
(
genTime('M4','Sunday less 4 weeks');
DTE1=M4DD + "-" + M4MM + "-" + M4YEAR;
if ( M4MM == APPL._SMM )
{
genTime('M5','Sunday less 5 weeks');
DTE1=M5DD + "-" + M5MM + "-" + M5YEAR;
}
}
}
}
2¢
Don
Original Message:
Sent: 01-31-2020 10:15 AM
From: Kenneth Chrapczynski
Subject: CAWA DE - create monthly and quarterly date variables
Hey Don,
In an effort to keep this simple I worded my request based on last Sunday of month. I figured if I get some very inventive solutions I can run with those and adjust it to my real world need.
The date being used isn't always the last Sunday (I lied :) ). This is for payroll so I do have situations where I have 3,4 and 5 week spans. In looking real close at the whole year it looks like the month-end date I'm using is the Sunday of the last full week in the month. Feb, Mar, Apr, Jun, Aug, Sep, Nov are 3 week spans.
Our motto in scheduling has always been if you can say it we can schedule it! I think there are teams who are trying to break us, lol!
I really appreciate you advise, thanks!!
KSki
Original Message:
Sent: 01-31-2020 09:29 AM
From: Don Powell
Subject: CAWA DE - create monthly and quarterly date variables
Hi,
I believe this will satisfy every scenario.
The logic is this. If it goes back 4 Sundays and it is still in the current month it will go back 5 Sundays to the previous month.
I suggest testing it for every scenario...
genTime('M2','Sunday less 4 weeks');
DTE1=M2DD + "-" + M2MM + "-" + M2YEAR;
if ( M2MM == APPL._SMM )
{
genTime('M3','Sunday less 5 weeks');
DTE1=M3DD + "-" + M3MM + "-" + M3YEAR;
}
2¢
Don
Original Message:
Sent: 01-31-2020 08:50 AM
From: Don Powell
Subject: CAWA DE - create monthly and quarterly date variables
Hi
I will play with this a little bit. I think I can make it work in every case. I will have to add some logic for the 4 or 5 week scenario. The 3 week does not come into play since subtracting 3 weeks(21 days) from 26th never gets back to the previous month.
Today does not look good but I will see if I can test something on Monday....
2¢
Don
Original Message:
Sent: 01-30-2020 02:42 PM
From: Don Powell
Subject: CAWA DE - create monthly and quarterly date variables
Hey there....
I did not test this but it may work.... I would want to test out every scenario.... depending on what day the 26th falls on...
genTime('M2','Sunday less 4 weeks');
I think if that is not complex enough we could determine when it should subtract 4 or 5 weeks.......
2¢
Don
Original Message:
Sent: 01-30-2020 01:56 PM
From: Kenneth Chrapczynski
Subject: CAWA DE - create monthly and quarterly date variables
Does anyone have samples of creating Monthly or Quarterly date variables? Or links to sites that can help me determine the syntax for wording scheduling criteria appropriately?
Example of Monthly -
Job scans in on the 1/26/2020, and I need to calculate the last Monday of the previous month resulting in 12/29/2019.
In my example below saying "less 1 month" calculates 30 days from the 26th and creates a variable (26-12-2019). How do I say last Sunday previous month?
genTime('M2','Sunday this week less 1 month');
APPL.PSTHRU2=M2DD + "-" + M2MM + "-" + M2YEAR;
Having fun? I also need a solution for a Quarterly date.
Same scenario job scans in on 3/22/2020, and I need to calculate back to 12/29/2019.
genTime('Q2','Sunday this week less 3 months');
APPL.PSTHRU3=Q2DD + "-" + Q2MM + "-" + Q2YEAR;