problem with Add/Sub and date

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
pstephens
Newbie
Posts: 2
Joined: Fri Oct 25, 2002 12:36 pm

problem with Add/Sub and date

Post by pstephens » Fri Oct 25, 2002 12:58 pm

I am trying to get the previous days date, and I ran across this code in the 'Tips' section:

GetDate>today
Sub>today,1
MidStr>today,1,2,d
Let>d=d-1
If>d=0,Start
Goto>End

Label>Start
..
Message>Today Is The Last Day of The Month!
..
Label>End

The problem is that when I try to run this, I get an error on the 'Sub' statement: 'Invalid Numeric or Date Format' :evil:
Our dates are in a mm/dd/yyyy format - is this the problem? If so, how can I change the format? Any help would be greatly appreciated!!

Thanks!

Ernest

problem with Add/Sub and date

Post by Ernest » Mon Oct 28, 2002 5:28 pm

Hi,
correct me if I'm wrong,
the GetDate>command takes the local (regional) setting from your PC.
The complete date string e.g. "10/28/2002" is difficult to sub cause it's not a numeric value!
If you would use the Day>command instead, it takes just the days value "28" which shouldn't be a problem to process.

Rgds.
Ernest

Check this out:

Code: Select all

Day>today
Month>month
Year>year
Let>Date, %month%/%today%/%year%

Sub>today,1 
MidStr>today,1,2,d 
Let>d=d-1 
If>d=0,Start 
Goto>End 

Label>Start 
.. 
Message>%Date% is definitely the last day of this month! %CRLF%Trust me !
.. 
Label>End

Ernest

problem with Add/Sub and date - second try :-)

Post by Ernest » Mon Oct 28, 2002 6:25 pm

Expect the unexpected :o
I've cut&pasted your script to create the local script for testing (which I assume you've done with the sample script).
Had the same problem.
I checked the variable(s). And guess, the GetDate>result variable has had an additional "invisible" space at the end*.
So we've tried to process an "unknown" (cause spaceless) and therefore empty variable with the sub>command!!!
After I've replaced the variable with the "original" matching one, your script hasn't stopped. Bingo.

Please ignore the c... I've posted prior to this :?
Ernest


*It's somethig I've often recognized with MSched, after I've saved a script to run it from scratch.

pstephens
Newbie
Posts: 2
Joined: Fri Oct 25, 2002 12:36 pm

[b]Thanks!!!!![/b]

Post by pstephens » Mon Oct 28, 2002 6:43 pm

:D I'm a happy camper!!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts