if I have a file 11-11xxxx
how do the script know 11of nov is sunday to change it to
sunxxxx
thanks
How to know which day of the week from the calendar
Moderators: Dorian (MJT support), JRL
If you want to out put the day of the week as text, the following will do that for you. This is taken from Macro Scheduler Help with a little added in to format the date as requested.
Rory
Month>month_result
Year>year_result
Day>day_result
DayOfWeek>result
Goto>Day%result%
Label>Day1
Let>DayString=Sunday
Goto>Continue
Label>Day2
Let>DayString=Monday
Goto>Continue
Label>Day3
Let>DayString=Tuesday
Goto>Continue
Label>Day4
Let>DayString=Wednesday
Goto>Continue
Label>Day5
Let>DayString=Thursday
Goto>Continue
Label>Day6
Let>DayString=Friday
Goto>Continue
Label>Day7
Let>DayString=Saturday
Goto>Continue
Label>Continue
If>month_result=1
Let>Month=January
ENDIF
If>month_result=2
Let>Month=February
ENDIF
If>month_result=3
Let>Month=March
ENDIF
If>month_result=4
Let>Month=April
ENDIF
If>month_result=5
Let>Month=May
ENDIF
If>month_result=6
Let>Month=June
ENDIF
If>month_result=7
Let>Month=July
ENDIF
If>month_result=8
Let>Month=August
ENDIF
If>month_result=9
Let>Month=September
ENDIF
If>month_result=10
Let>Month=October
ENDIF
If>month_result=11
Let>Month=November
ENDIF
If>month_result=12
Let>Month=December
ENDIF
MessageModal>%DayString%, %Month% %day_result%, %year_result%
Rory
Month>month_result
Year>year_result
Day>day_result
DayOfWeek>result
Goto>Day%result%
Label>Day1
Let>DayString=Sunday
Goto>Continue
Label>Day2
Let>DayString=Monday
Goto>Continue
Label>Day3
Let>DayString=Tuesday
Goto>Continue
Label>Day4
Let>DayString=Wednesday
Goto>Continue
Label>Day5
Let>DayString=Thursday
Goto>Continue
Label>Day6
Let>DayString=Friday
Goto>Continue
Label>Day7
Let>DayString=Saturday
Goto>Continue
Label>Continue
If>month_result=1
Let>Month=January
ENDIF
If>month_result=2
Let>Month=February
ENDIF
If>month_result=3
Let>Month=March
ENDIF
If>month_result=4
Let>Month=April
ENDIF
If>month_result=5
Let>Month=May
ENDIF
If>month_result=6
Let>Month=June
ENDIF
If>month_result=7
Let>Month=July
ENDIF
If>month_result=8
Let>Month=August
ENDIF
If>month_result=9
Let>Month=September
ENDIF
If>month_result=10
Let>Month=October
ENDIF
If>month_result=11
Let>Month=November
ENDIF
If>month_result=12
Let>Month=December
ENDIF
MessageModal>%DayString%, %Month% %day_result%, %year_result%
It does not work all the time
The script can out put the date as text, but it wouldnot work all the time let say I have a file name:
11-11xxxx. for november, the 11th is Sunday, so =Nov-11Sundayxx
if I have a file 12-11xxxx, the 11th is now Tuesday not Sunday.
11-11xxxx. for november, the 11th is Sunday, so =Nov-11Sundayxx
if I have a file 12-11xxxx, the 11th is now Tuesday not Sunday.
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Here's how I would do it. I'm assuming the year is 2007. You don't specify the year anywhere, and that would of course have a bearing on the day of the week:
Code: Select all
VBSTART
Dim DayArray
DayArray = array("sun","mon","tue","wed","thu","fri","sat")
VBEND
Let>FileName=12-11xxxx.txt
Let>Month={Copy(%FileName%,1,2)}
Let>Day={Copy(%FileName%,4,2)}
VBEval>WeekDay(DateSerial(2007,%Month%,%Day%)),d
VBEVal>DayArray(%d%),DayName
Let>rest={Copy(%FileName%,6,Length(%FileName%))}
Let>NewFile=%DayName%%rest%
MessageModal>NewFile
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?
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Yes. If the year is always to be the current year then you could just change the code to:
Note 2007 has been replaced with Year(now)
Code: Select all
VBSTART
Dim DayArray
DayArray = array("sun","mon","tue","wed","thu","fri","sat")
VBEND
Let>FileName=12-11xxxx.txt
Let>Month={Copy(%FileName%,1,2)}
Let>Day={Copy(%FileName%,4,2)}
VBEval>WeekDay(DateSerial(Year(Now),%Month%,%Day%)),d
VBEVal>DayArray(%d%),DayName
Let>rest={Copy(%FileName%,6,Length(%FileName%))}
Let>NewFile=%DayName%%rest%
MessageModal>NewFile
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?
dayname is one day ahead
when I change FileName=11-11xxxx.txt
the NewFile= monday the correct date should be Sunday
if I change the date to11-10xxx.txt, I have vbscript error
thanks
the NewFile= monday the correct date should be Sunday
if I change the date to11-10xxx.txt, I have vbscript error
thanks
Last edited by timle on Wed Nov 14, 2007 10:16 pm, edited 1 time in total.
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Oops. I forgot the array indexing starts with 0. So you need to subtract one from the day number. The correct code is:
I think that should fix it.
Code: Select all
VBSTART
Dim DayArray
DayArray = array("sun","mon","tue","wed","thu","fri","sat")
VBEND
Let>FileName=11-11xxxx.txt
Let>Month={Copy(%FileName%,1,2)}
Let>Day={Copy(%FileName%,4,2)}
VBEval>WeekDay(DateSerial(Year(Now),%Month%,%Day%)),d
VBEVal>DayArray(%d%-1),DayName
Let>rest={Copy(%FileName%,6,Length(%FileName%))}
Let>NewFile=%DayName%%rest%
MessageModal>NewFile
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?