math on GET DATE
Moderators: JRL, Dorian (MJT support)
-
- Newbie
- Posts: 7
- Joined: Sun Jan 25, 2004 12:57 am
math on GET DATE
Hi,
I need to rename the file inserting yesterday's date;
'GetDate
Day>the_day
month>the_month
Year>the_year
MidStr>%the_year%,3,4,year
Sub>the_day,1
Let>BSC=d:\local\ACTIVITY.DAT
Let>bct=d:\local\%year%%the_month%%the_day%.bct
MoveFile>BSC,bct
all works fine as long the day is between 11 and 31st
the first ten days of the month return the yy/mm/d while expecting yy/mm/dd
any idea or hint to approach better my problem would be appreciated
thanks
mark
I need to rename the file inserting yesterday's date;
'GetDate
Day>the_day
month>the_month
Year>the_year
MidStr>%the_year%,3,4,year
Sub>the_day,1
Let>BSC=d:\local\ACTIVITY.DAT
Let>bct=d:\local\%year%%the_month%%the_day%.bct
MoveFile>BSC,bct
all works fine as long the day is between 11 and 31st
the first ten days of the month return the yy/mm/d while expecting yy/mm/dd
any idea or hint to approach better my problem would be appreciated
thanks
mark
Try this. You were going to also have trouble on the first of the month since subtracting one from one would leave you with zero.
Code: Select all
Day>the_day
month>the_month
Year>the_year
Let>today=%the_month%/%the_day%/%the_year%
Sub>today,1
Separate>today,/,var
If>{(%var_1%=1)or(%var_1%=2)or(%var_1%=3)or(%var_1%=4)or(%var_1%=5)or(%var_1%=6)or(%var_1%=7)or(%var_1%=8)or(%var_1%=9)}
Let>var_1=0%var_1%
EndIf
If>{(%var_2%=1)or(%var_2%=2)or(%var_2%=3)or(%var_2%=4)or(%var_2%=5)or(%var_2%=6)or(%var_2%=7)or(%var_2%=8)or(%var_2%=9)}
Let>var_2=0%var_2%
EndIf
midstr>var_3,3,2,var_3
Let>BSC=d:\local\ACTIVITY.DAT
Let>bct=d:\local\%var_3%%var_1%%var_2%.bct
MoveFile>BSC,bct
-
- Newbie
- Posts: 7
- Joined: Sun Jan 25, 2004 12:57 am
math on GET DATE
Hi,
thanks for the code. I do not think I understand the SEPARATE function and I am not sure if I adjusting your code as below would work for me
in your example the date string is
%the_month%/%the_day%/%the_year%
and the final line is
%var_3%%var_1%%var_2%
the date string I need
%year%%the_month%%the_day%
should my final line read
%var_2%%var_3%%var_1%
thanks
thanks for the code. I do not think I understand the SEPARATE function and I am not sure if I adjusting your code as below would work for me
in your example the date string is
%the_month%/%the_day%/%the_year%
and the final line is
%var_3%%var_1%%var_2%
the date string I need
%year%%the_month%%the_day%
should my final line read
%var_2%%var_3%%var_1%
thanks
-
- Automation Wizard
- Posts: 1101
- Joined: Fri Jan 07, 2005 5:55 pm
- Location: Somewhere else on the planet
Lots of info on getting yesterday's date here http://www.mjtnet.com/usergroup/viewtop ... =yesterday
if the link from Me_Again covers this, forgive me, but here is the easiest way to get the date in the format you want.
control panel, regional settings, the customize button by your current location, then the date tab. Select the format of MM/DD/YYYY
then use
vbstart
vbend
vbe>Date()-1,mydate
now mydate will contain MM/DD/YYYY
control panel, regional settings, the customize button by your current location, then the date tab. Select the format of MM/DD/YYYY
then use
vbstart
vbend
vbe>Date()-1,mydate
now mydate will contain MM/DD/YYYY
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
No need to mess about with regional settings. This is my solution:
Code: Select all
VBSTART
VBEND
VBEval>Year(Date()-1) & Right("0" & Month(Date()-1),2) & Right("0" & Day(Date()-1),2),yDateString
Last edited by Marcus Tettmar on Mon Dec 04, 2006 6:26 pm, edited 1 time in total.
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?
This worked great after I removed the extra VBEval> (there were two in the code above as originally posted):

Nice little piece of code, thanks Marcus... added to snipets.mtettmar wrote:VBSTART
VBEND
VBEval>VBEval>Year(Date()-1) & Right("0" & Month(Date()-1),2) & Right("0" & Day(Date()-1),2),yDateString

jpuziano
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -
Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post -

- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Oops. Have edited my post and removed the erroneous extra VBEval.
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?