Hello,
I have 12version, is it possible to get yesterday date ?
Yesterday date
Moderators: Dorian (MJT support), JRL
- Dorian (MJT support)
- Automation Wizard
- Posts: 1389
- Joined: Sun Nov 03, 2002 3:19 am
- Contact:
Re: Yesterday date
Sadly v12 was released 13 years ago so is out of support.
The usual way of doing this would be :
But unfortunately DateAdd was only added in v13, 12 years ago.
GetDate was in v12 though, so that would at least be a starting point.
The usual way of doing this would be :
Code: Select all
GetDate>today
DateAdd>today,D,-1,yesterday
GetDate was in v12 though, so that would at least be a starting point.
Yes, we have a Custom Scripting Service. Message me or go here
Re: Yesterday date
This should work in version 4 onward.
Code: Select all
//Pure Macro Scheduler
Month>mm
Day>dd
Year>yyyy
Let>today=%mm%/%dd%/%yyyy%
Sub>today,1
//Variable today is now yesterday's date.
MDL>today
//Or VBScript
VBStart
VBEnd
VBEval>now-1,yesterday
MDL>yesterday
//The result is date and time
//To have only the date
Separate>yesterday,space,vNow
MDL>vNow_1
- Dorian (MJT support)
- Automation Wizard
- Posts: 1389
- Joined: Sun Nov 03, 2002 3:19 am
- Contact:
Re: Yesterday date
Thank you for that. I'm quite amazed that Sub>today,1 detected the date correctly like that.JRL wrote: ↑Fri Mar 17, 2023 1:54 pmThis should work in version 4 onward.
Code: Select all
//Pure Macro Scheduler Month>mm Day>dd Year>yyyy Let>today=%mm%/%dd%/%yyyy% Sub>today,1 //Variable today is now yesterday's date. MDL>today //Or VBScript VBStart VBEnd VBEval>now-1,yesterday MDL>yesterday //The result is date and time //To have only the date Separate>yesterday,space,vNow MDL>vNow_1
Seeing as GetDate was also in v12, this should also work :
Code: Select all
GetDate>today
Sub>today,1
Yes, we have a Custom Scripting Service. Message me or go here
Re: Yesterday date
I don't want to change my regional date setting to test but as I recall GetDate> presents in the format specified in regional settings. For Add> and Sub> to work with a date the date has to be in month/day/year format. No other format will work. You can use 1 digit month and day as well as 2 digit year, but the date has to be month/day/year. Another caveat if you use 2 digit year is that you can get the wrong century. 72 and smaller will give you a 20xx result but 73 though 99 will provide a 19xx result. No issues at all if you use a 4 digit year.
If you are working far into the past or future you can acquire a 5 or more digit result for the year, but you can't use more than a 4 digit year for input. Nor can you acquire a result or use an input less than 1/1/0001
If you are working far into the past or future you can acquire a 5 or more digit result for the year, but you can't use more than a 4 digit year for input. Nor can you acquire a result or use an input less than 1/1/0001
Re: Yesterday date
JRL wrote: ↑Fri Mar 17, 2023 1:54 pmThis should work in version 4 onward.
Code: Select all
//Pure Macro Scheduler Month>mm Day>dd Year>yyyy Let>today=%mm%/%dd%/%yyyy% Sub>today,1 //Variable today is now yesterday's date. MDL>today //Or VBScript VBStart VBEnd VBEval>now-1,yesterday MDL>yesterday //The result is date and time //To have only the date Separate>yesterday,space,vNow MDL>vNow_1
Thank you!!!
- Dorian (MJT support)
- Automation Wizard
- Posts: 1389
- Joined: Sun Nov 03, 2002 3:19 am
- Contact:
Re: Yesterday date
I just had reason to try this and can confirm that the Sub method still works even if the local date format is DD/MM/YYYY. I also tested Add, and that worked too.
Code: Select all
//My local (UK) format DD/MM/YYYY
//Output : 14/04/2023
GetDate>today
//Output : 13/04/2023
Sub>today,1
Yes, we have a Custom Scripting Service. Message me or go here