I want to subtract 10 days from the current date.
I execute the following commands:
Day>the_day
Sub>the_day,10
Since today is the 6th, it returns the value -4.
The help file states that Sub can be used with dates or numbers. I would think it is smart enough to recognize the number or days in the month if it can be used for dates.
Am I doing something wrong?
Using subtract function with dates
Moderators: Dorian (MJT support), JRL
-
- Automation Wizard
- Posts: 1101
- Joined: Fri Jan 07, 2005 5:55 pm
- Location: Somewhere else on the planet
Re: Using subtract function with dates
It does work with a date:josh432 wrote:The help file states that Sub can be used with dates or numbers.
GetDate>date1
Let>date2=date1
Sub>date2,10
MessageModal>%date1% %date2%
but when you use Day> all you are doing is storing the day number in a variable, that variable doesn't have any connection to the month to know what 10 days before the 6th would be.
There are a bunch of examples on this forum of date arithmetic.
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Sub can subtract days from dates. So you can do:
To return today's date minus 10 days.
But you are just subtracting 10 from the current day number. Day returns the day of the month - which is just a number. So 6 - 10 is -4.
Code: Select all
GetDate>the_date
Sub>the_date,10
But you are just subtracting 10 from the current day number. Day returns the day of the month - which is just a number. So 6 - 10 is -4.
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?