Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Help with script involving dates and days of week  (Read 12849 times)

0 Members and 1 Guest are viewing this topic.

Fields



    Beginner

    Thanked: 3
    Re: Help with script involving dates and days of week
    « Reply #30 on: August 27, 2010, 01:29:11 PM »
    When I back up against another month it fails also.

    Can the day of the week that corresponds to the date be returned as a variable?



    The batch/vbs will accept any number of days (forward or back ) as a command line argument for the batch.
    Echo and redirect (>) modifies the vbs files.  The command line argument must include + or -


    C:test>Display  forbac.bat

    @echo off

    echo Wscript.Echo Now %1  > backday.vbs
    CScript //nologo  backday.vbs  > back.txt
    set /p back=<back.txt
    set back=%back:~0,9%

    echo Now%1=%back%
    echo From Now %1 days

    echo Wscript.Echo WeekdayName(Weekday(Now %1)) > day.vbs

    cscript //nologo  day.vbs  > weekday.txt

    set /p weekday=<weekday.txt

    set weekday=%weekday:~0,3%

    echo weekday%1=%weekday%

    echo From Now %1 days

    Output:

    C:test> forbac.bat  +130
    Now+130=1/3/2011
    From Now +130 days
    weekday+130=Mon
    From Now +130 days

    Output:

    C:test> forbac.bat  -130
    Now-130=4/18/2010
    From Now -130 days
    weekday-130=Sun
    From Now -130 days

    C:test>

    ______________________________

    It is now:
    Thu 08/26/2010
    Member of the Human Race; Citizen of the World.