Marcus once sent me a script to derive the day of the year in MacroScheduler. I had a, let's say, C-R-A-S-H a short time ago and lost many things. Once of them, this MacroScheduler scp. I do not have VB, so does anyone have a script that does this in a nice, understandable way?
Jerry.
A script to derive the day of the year (001-365) ?
Moderators: Dorian (MJT support), JRL
-
- Newbie
- Posts: 6
- Joined: Tue Sep 16, 2003 2:22 pm
- Contact:
And then after I hit submit, I see "do not have VB". (Consider upgrading )
There have been a few threads about such a "Date Count" script. Here is one shows how to count without VB: http://www.mjtnet.com/usergroup/viewtopic.php?t=210
Here's an example for your use:Let>DateStart=1/1/2003
Let>DayCount=0
GetDate>Today
Label>CheckIfToday
If>Today=DateStart,TodayFound
Sub>Today,1
Add>DayCount,1
Goto>CheckIfToday
Label>TodayFound
MessageModal>Non-VB day count = %DayCount%
The VBScript version runs almost instantly, but the Non-VB version can take a few seconds.
There have been a few threads about such a "Date Count" script. Here is one shows how to count without VB: http://www.mjtnet.com/usergroup/viewtopic.php?t=210
Here's an example for your use:Let>DateStart=1/1/2003
Let>DayCount=0
GetDate>Today
Label>CheckIfToday
If>Today=DateStart,TodayFound
Sub>Today,1
Add>DayCount,1
Goto>CheckIfToday
Label>TodayFound
MessageModal>Non-VB day count = %DayCount%
The VBScript version runs almost instantly, but the Non-VB version can take a few seconds.
-
- Newbie
- Posts: 6
- Joined: Tue Sep 16, 2003 2:22 pm
- Contact:
-
- Newbie
- Posts: 6
- Joined: Tue Sep 16, 2003 2:22 pm
- Contact:
This one works like a charm...
Thanks. It works like a charm...
Two things:
1. The date is dependent on your Windows regional settings.
2. The DayCount loop has to start with a value of 1.
Finally, I almost used a flat file read approach, which also would have worked. But, your solution is simpler and more elegant. Does the read approach run faster? Hmmm.... maybe I should try it just for the heck of it.
Anyway, thanks again for your help.
Jerry.
[quote="Captive"]And then after I hit submit, I see "do not have VB". (Consider upgrading )
There have been a few threads about such a "Date Count" script. Here is one shows how to count without VB: [url]http://www.mjtnet.com/forum/viewtopic.php?t=210[/url]
Here's an example for your use:Let>DateStart=1/1/2003
Let>DayCount=0
GetDate>Today
Label>CheckIfToday
If>Today=DateStart,TodayFound
Sub>Today,1
Add>DayCount,1
Goto>CheckIfToday
Label>TodayFound
MessageModal>Non-VB day count = %DayCount%
The VBScript version runs almost instantly, but the Non-VB version can take a few seconds.[/quote]
Two things:
1. The date is dependent on your Windows regional settings.
2. The DayCount loop has to start with a value of 1.
Finally, I almost used a flat file read approach, which also would have worked. But, your solution is simpler and more elegant. Does the read approach run faster? Hmmm.... maybe I should try it just for the heck of it.
Anyway, thanks again for your help.
Jerry.
[quote="Captive"]And then after I hit submit, I see "do not have VB". (Consider upgrading )
There have been a few threads about such a "Date Count" script. Here is one shows how to count without VB: [url]http://www.mjtnet.com/forum/viewtopic.php?t=210[/url]
Here's an example for your use:Let>DateStart=1/1/2003
Let>DayCount=0
GetDate>Today
Label>CheckIfToday
If>Today=DateStart,TodayFound
Sub>Today,1
Add>DayCount,1
Goto>CheckIfToday
Label>TodayFound
MessageModal>Non-VB day count = %DayCount%
The VBScript version runs almost instantly, but the Non-VB version can take a few seconds.[/quote]
Re: This one works like a charm...
Which makes the VBScript even better. If it is a problem, you can probably get around it by reading a registry string somewhere, or figuring out by analying the results of GetDate (and then just getting the date of tomorrow/yesterday, to see which entry changed and thus is the date field.)Jerry Gilels wrote:1. The date is dependent on your Windows regional settings.
Ahh right. I was basing it off the number of days *since* 01/01.Jerry Gilels wrote:2. The DayCount loop has to start with a value of 1.
A request if I may - please don't quote all of the previous message whenever you make a post. Both times my message was right there, above your post.