Here's my scenario:
We run a report on the first business day of the month. We have to go into the application and set some variables and then click "RUN"
There are two variables I have a problem with:
YEAR: There is a field where I have to enter a year as 2008 for example. How can I tell the script to look at whatever the current year and insert it into field?
DATE -> PERIOD: This one is harder. We start the fiscal year in July. Each month is a "period" so July is 1, August is 2, etc... up to the 12th period which is June.
How do I tell the script to match the months to those period numbers? and then I need to insert the PREVIOUS MONTH's period number into the report field....
so for example, January is period 7 so on February 1st the script needs to insert the number 7 into the field
I hope this makes sense - and someone can help!!!
Can I link date to a "period" number and have it a
Moderators: JRL, Dorian (MJT support)
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
To get the current year use the, er, Year command:
Year>theYear
Then you can send it to the field with:
Send>theYear
To convert a month to a period, first use the Month command to get the current month number. Then we need to translate it. All we need is a simple calculation:
To determine the previous month number do:
Year>theYear
Then you can send it to the field with:
Send>theYear
To convert a month to a period, first use the Month command to get the current month number. Then we need to translate it. All we need is a simple calculation:
Code: Select all
Month>mm
If>mm>6
Let>period=mm-6
Else
Let>period=mm+6
Endif
Code: Select all
Month>mm
Let>mm=mm-1
If>mm=0
Let>mm=12
Endif
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Thanks Marcus,
I understand the year variable now but have another question about the month variable.
I'm not totally user I understand the month variable (the +/- 6 part) but no worries, we'll roll with it
When I get to the part of the script where I actually want to insert the period value, would I use this piece of the script there?
Or would I include that with the +/- 6 piece at the top of the script?
If the latter, what "SEND" command do I use to insert the period's value?
I understand the year variable now but have another question about the month variable.
I'm not totally user I understand the month variable (the +/- 6 part) but no worries, we'll roll with it

When I get to the part of the script where I actually want to insert the period value, would I use this piece of the script there?
Code: Select all
Month>mm
Let>mm=mm-1
If>mm=0
Let>mm=12
Endif
If the latter, what "SEND" command do I use to insert the period's value?
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Please read my last post again carefully. The bit you quote above is the bit that determines what LAST month was. When you want to do that you need to do it before calculating the period. Do it IN PLACE of Month>mm in my first snippet.Brett wrote: When I get to the part of the script where I actually want to insert the period value, would I use this piece of the script there?
Or would I include that with the +/- 6 piece at the top of the script?Code: Select all
Month>mm Let>mm=mm-1 If>mm=0 Let>mm=12 Endif
If the latter, what "SEND" command do I use to insert the period's value?
Yes, when you want to send the final result, use the Send command
And indeed you would want to send the calculated period value:
Send>period
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact: