General Macro Scheduler discussion
Moderators: Dorian (MJT support), JRL
-
edauthier
- Pro Scripter
- Posts: 84
- Joined: Sun Apr 13, 2003 1:26 pm
- Location: USA
Post
by edauthier » Mon Aug 04, 2008 1:33 am
Why doesn't this work?
Maybe a wish for wish for a
datesub> command to retain the 0's in front of month and day for date management functions...
I am looking to subtract one day from script execution day and the receiving systems require the leading zeros on month and day.
I had trouble posting the example script correctly. ..
Code: Select all
GetDate>date
sub>date,1
Separate>date,/,field
if>{(%field_1%<=9) and (%field_2%<=9)},add0monthday
else
if>{(%field_1%<=9) and (%field_2%=>10)},add0monthonly
else
if>{(%field_1%=>10) and (%field_2%<=9)},add0dayonly
else
if>{(%field_1%=>10) and (%field_2%=>10)},normal
endif
label>add0monthday
message>0%field_1%-0%field_2%-%field_3%
goto>end
label>add0monthonly
message>0%field_1% -%field_2%-%field_3%
goto>end
label>add0dayonly
message>%field_1% -0%field_2%-%field_3%
goto>end
label>normal
message>%field_1%-%field_2%-%field_3%
label>end
-
Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
-
Contact:
Post
by Marcus Tettmar » Mon Aug 04, 2008 7:12 am
Sub>date,1 *does* retain zeros for me. It should return the date in your system's short date format. For me the format is not changed when I use Sub>date,1.
However, if you want more control, use VBScript's date functions. E.g. The following subtracts one from the current date and also formats the date in month/day/year format ensuring the month and day are zero prefixed:
Code: Select all
VBSTART
VBEND
VBEval>Right("0" & DatePart("m", Now()),2) & "/" & Right("0" & DatePart("d", Now()),2) & "/" & DatePart("yyyy",Now()),date
-
edauthier
- Pro Scripter
- Posts: 84
- Joined: Sun Apr 13, 2003 1:26 pm
- Location: USA
Post
by edauthier » Tue Aug 05, 2008 1:21 am
Thanks very much. I am not sure why I do not have the leading zeros. This is on XP and Vista..
-
Me_again
- Automation Wizard
- Posts: 1101
- Joined: Fri Jan 07, 2005 5:55 pm
- Location: Somewhere else on the planet
Post
by Me_again » Tue Aug 05, 2008 3:01 am
Does the clock in the system tray have a leading zero? The format is set on Control Panel > Regional and Language > Customize > Time (unless you are using a third party clock utility).