I have a .bat file which executes some code after I enter a date in cmd:
test.bat contains:
- set /P PWeekday=asofdate:
Since i always enter the previous weekday i wanted to write some code that will do just that. But having found it very difficult to do as part of a batch script, I read that it's much easier to create a macro in excel and pass values into the command line for the batch script to run. So i done just that:
PWeekday function in VBA
Public Function PWeekday() As String
Dim offset Day As Integer
If Weekday(Date) = 1 Then ' Monday
offsetDay = 3
End If
PWeekDay = Format(Date - offsetDay, "YYYYMMDD")
End Function
Question:
What do I have to add to the batch file so that when i run it, it uses the Pweekday value from the vba function and not my user input?
Thank you very much, any help or advice will be appreciated.