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 12848 times)

0 Members and 1 Guest are viewing this topic.

mcgriff1969

    Topic Starter


    Rookie

    Help with script involving dates and days of week
    « on: August 15, 2010, 05:47:07 PM »
    Hi,

    I use a batch program to download files from a server.  The files are named [name]_[date in yyymmdd format].
    I wrote the program to download files for the last 7 days starting with today.  I have two problems:
    1.  When the program counts backwards I loose the leading zero so 20100804 becomes 201084 which doesn't work.
    2.  When I back up against another month it fails also.

    Can this be fixed.  Also can the day of the week that corresponds to the date be returned as a variable?

    Here is the code:

    SET dwMONTH=%DATE:~4,2%
    SET dwDAY=%DATE:~7,2%
    SET dwYEAR=%DATE:~10,4%
    SET Datenow=%dwYEAR%%dwMONTH%%dwDAy%

    :gs01
    set localroot=[server]
    set localdrv=d:
    copy %localroot%\FL_%plantid%_*%datenow%.txt %localdrv%\rs_input\FL_%plantid%_%datenow%.txt
    copy %localroot%\D1_%plantid%_*%datenow%.txt %localdrv%\rs_input\D1_%plantid%_%datenow%.txt


    SET dwMONTH=%DATE:~4,2%
    SET /A dwDAY=%DATE:~7,2%-1
    SET dwYEAR=%DATE:~10,4%
    SET Datenow=%dwYEAR%%dwMONTH%%dwDAy%

    copy %localroot%\FL_%plantid%_*%datenow%.txt %localdrv%\rs_input\FL_%plantid%_%datenow%.txt
    copy %localroot%\D1_%plantid%_*%datenow%.txt %localdrv%\rs_input\D1_%plantid%_%datenow%.txt

    An help is appreciated

    vishuvishal



      Beginner
    • Thanked: 3
      Re: Help with script involving dates and days of week
      « Reply #1 on: August 15, 2010, 06:10:44 PM »
      Here is the solution. There was small defect.


      Code: [Select]
      SET dwMONTH=%DATE:~4,2%
      SET dwDAY=%DATE:~7,2%
      SET dwYEAR=%DATE:~10,4%
      SET Datenow=%dwYEAR%%dwMONTH%%dwDAy%

      :gs01
      set localroot=[server]
      set localdrv=d:
      copy "%localroot%\FL_%plantid%_*%datenow%.txt" %localdrv%\rs_input\FL_%plantid%_%datenow%.txt
      copy "%localroot%\D1_%plantid%_*%datenow%.txt" %localdrv%\rs_input\D1_%plantid%_%datenow%.txt


      SET dwMONTH=%DATE:~4,2%
      SET /A dwDAY=%DATE:~7,2%
      SET dwYEAR=%DATE:~10,4%
      SET Datenow=%dwYEAR%%dwMONTH%%dwDAy%

      copy "%localroot%\FL_%plantid%_*%datenow%.txt" %localdrv%\rs_input\FL_%plantid%_%datenow%.txt
      copy "%localroot%\D1_%plantid%_*%datenow%.txt" %localdrv%\rs_input\D1_%plantid%_%datenow%.txt



      Checked and verified. This will work

      Please let me know if it all set.

      Thanks will do it.


      Thanks and regards
      vishu

      mcgriff1969

        Topic Starter


        Rookie

        Re: Help with script involving dates and days of week
        « Reply #2 on: August 15, 2010, 07:41:22 PM »
        Hi Vishu,

        I apologize for my lack of clarity the line: SET /A dwDAY=%DATE:~7,2%-1 is not really a defect.  It subtracts 1 day from the date.  the program counts backward for 6 days to copy files dated as I stated in the original post.  The subsequent groups of code have: SET /A dwDAY=%DATE:~7,2%-2, SET /A dwDAY=%DATE:~7,2%-1-3, etc. to SET /A dwDAY=%DATE:~7,2%-6.

        In the end I want 7 sets of files including the current day.

        vishuvishal



          Beginner
        • Thanked: 3
          Re: Help with script involving dates and days of week
          « Reply #3 on: August 16, 2010, 03:39:59 PM »
          Here is the solution. There was small defect.


          Code: [Select]
          SET dwMONTH=%DATE:~4,2%
          SET dwDAY=%DATE:~7,2%
          SET dwYEAR=%DATE:~10,4%
          SET Datenow=%dwYEAR%%dwMONTH%%dwDAy%

          :gs01
          set localroot=[server]
          set localdrv=d:
          copy "%localroot%\FL_%plantid%_*%datenow%.txt" %localdrv%\rs_input\FL_%plantid%_%datenow%.txt
          copy "%localroot%\D1_%plantid%_*%datenow%.txt" %localdrv%\rs_input\D1_%plantid%_%datenow%.txt


          SET dwMONTH=%DATE:~4,2%
          SET /A dwDAY=%DATE:~7,2%-1
          IF /i %dwDAY% LSS 10 set dwday=0%dwDAY%
          SET dwday=%0%%dwday%
          SET dwYEAR=%DATE:~10,4%
          SET Datenow=%dwYEAR%%dwMONTH%%dwDAy%

          copy "%localroot%\FL_%plantid%_*%datenow%.txt" %localdrv%\rs_input\FL_%plantid%_%datenow%.txt
          copy "%localroot%\D1_%plantid%_*%datenow%.txt" %localdrv%\rs_input\D1_%plantid%_%datenow%.txt



          Checked and verified. This will work

          Please let me know if it all set.

          Thanks will do it.


          Thanks and regards
          vishu

          Dusty



            Egghead

          • I could if she would, but she won't so I don't.
          • Thanked: 75
          • Experience: Beginner
          • OS: Windows XP
          Re: Help with script involving dates and days of week
          « Reply #4 on: August 16, 2010, 05:10:51 PM »
          Batch scripting is all but useless in manipulating dates.

          What happens if the day is 01?  The result of SET /A dwDAY=%DATE:~7,2%-1 is that dwDAY will return zero ???, and if the day is 02 and you "count backwards" for six days, dwDay will return -4.

          Also, if the day is 08 or 09 Set /a will treat the values as Octal and throw up the usual error message because 08 and 09 are invalid in octal.

          If the script is run near the beginning of the month, month and day must be decremented.  If you run the script in early January the day, month and year must be decremented.

          Best have a look at date manipulation using VB scripting.

          Good luck.
          One good deed is worth more than a year of good intentions.

          RoyBailey



            Rookie

            Help with script involving dates and days of week
            « Reply #5 on: August 16, 2010, 07:28:58 PM »
            C:test>type griff816.bat
            @echo off
            set /a c=0
            :start
            SET dwMONTH=%DATE:~4,2%
            echo dwMONTH=%dwMONTH%
            SET /A dwDAY=%DATE:~7,2% -%c%
            echo dwDAY=%dwDAY%
            SET dwDAY=%DATE:~7,2%
            SET dwYEAR=%DATE:~10,4%
            SET Datenow=%dwYEAR%%dwMONTH%%dwDAy%


            set localroot=c:test
            set localdrv=c:tmp
            copy  %localroot%\\%datenow%.txt %localdrv%\\%datenow%.txt
            copy  %localroot%\\%datenow%.txt %localdrv%\\%datenow%.txt


            SET dwMONTH=%DATE:~4,2%
            SET /A dwDAY=%DATE:~7,2% -%c%
            echo dwDAY=%dwDAY%
            if %dwDAY% LEQ 0 (
            SET /a dwDAY=31
            SET /a dwMONTH=%DATE:~5,1% -1
            echo dwMONTH=%dwMONTH%
            if %dwMONTH% EQU 7 set /a dwDAY=31
            if %dwMONTH% EQU 8 set /a dwDAY=31
            if %dwMONTH% EQU 6 set /a dwDAY=30
            if %dwMONTH% EQU 2 set /a dwDAY=28
            echo dwDAY=%dwDAY%
            )
            if %dwMONTH% LEQ 9 set dwMONTH=0%dwMONTH%
            echo dwMONTH=%dwMONTH%
            SET dwYEAR=%DATE:~10,4%
            SET Datenow=%dwYEAR%%dwMONTH%%dwDAy%
            echo Datenow=%Datenow%
            if %dwDAY% LEQ 9 set dwDAY=0%dwDAY%

            copy %localroot%\\FL_%plantid%_*%datenow%.txt %localdrv%\\rs_input\\FL_%plantid%_%datenow%.txt
            copy %localroot%\\\\D1_%plantid%_*%datenow%.txt %localdrv%\\\\rs_input\\\\D1_%plantid%_%datenow%.txt
            set /a c=%c% + 1
            if %c% LEQ 7 goto :start


            C:test>
            USA

            mcgriff1969

              Topic Starter


              Rookie

              Re: Help with script involving dates and days of week
              « Reply #6 on: August 23, 2010, 01:51:44 PM »
              Hi Roy,

              I tried your code but it placed a zero in front all dates even if there were already 2 digits.  But I like your logic here.  I'm trying this but it isn't working quite right either. Any thoughts?

              set /a addzero=0
              SET dwMONTH=%DATE:~4,2%
              SET /A dwDAY=%DATE:~7,2%-14
              SET dwYEAR=%DATE:~10,4%
              if (%dwday%) GEQ (10) (
              set /a datenow=%dwYEAR%%dwMONTH%%dwDAy%
              ) else (
              SET /a Datenow=%dwyear%%dwmonth%%addzero%%dwday%
              )

              echo %datenow%

              ghostdog74



                Specialist

                Thanked: 27
                Re: Help with script involving dates and days of week
                « Reply #7 on: August 23, 2010, 07:10:28 PM »
                here comes the expert Roy. Don't worry mcgriff1969, Roy will solve your problem using batch. As for my recommendation, i would suggest you use some other tools able to manipulate dates better, eg vbscript. you can search the forum as there are many such vbscripts lying around.

                mcgriff1969

                  Topic Starter


                  Rookie

                  Re: Help with script involving dates and days of week
                  « Reply #8 on: August 25, 2010, 08:31:58 AM »
                  here comes the expert Roy. Don't worry mcgriff1969, Roy will solve your problem using batch. As for my recommendation, i would suggest you use some other tools able to manipulate dates better, eg vbscript. you can search the forum as there are many such vbscripts lying around.

                  Wow!  No love for Roy?  :o

                   I understand that VB Script is better for this but I have zero knowledge of it.

                  Helpmeh



                    Guru

                  • Roar.
                  • Thanked: 123
                    • Yes
                    • Yes
                  • Computer: Specs
                  • Experience: Familiar
                  • OS: Windows 8
                  Re: Help with script involving dates and days of week
                  « Reply #9 on: August 25, 2010, 09:09:25 AM »
                  Wow!  No love for Roy?  :o
                  No patience for Roy, or any of his other accounts.
                  Where's MagicSpeed?
                  Quote from: 'matt'
                  He's playing a game called IRL. Great graphics, *censored* gameplay.

                  Fields



                    Beginner

                    Thanked: 3
                    Help with script involving dates and days of week
                    « Reply #10 on: August 25, 2010, 09:45:16 AM »

                    I tried your code but it placed a zero in front all dates even if there were already 2 digits.  But I like your logic here.  I\'m trying this but it isnt working quite right either. Any thoughts?

                    echo %datenow%

                    Many suggestions from the Ghost and Helpless about what does not work.

                    But no suggestions or examples from the Ghost and Helpless of what can be done.

                    The Cat Bell?
                    Member of the Human Race; Citizen of the World.

                    Fields



                      Beginner

                      Thanked: 3
                      Help with script involving dates and days of week
                      « Reply #11 on: August 25, 2010, 11:26:00 AM »

                      I tried your code but it placed a zero in front all dates even if there were already 2 digits.  But I like your logic here.  Im trying this but it isnt working quite right either.

                      Any thoughts?


                      C:test>Display  mc.bat

                      @echo off
                      SET dwMONTH=%DATE:~4,2%
                      echo dwMONTH=%dwMONTH%
                      SET /A dwDAY=%DATE:~7,2%-16
                      echo dwDAY=%dwDAY%
                      SET dwYEAR=%DATE:~10,4%
                      echo dwYEAR=%dwYEAR%
                      if %dwday% LEQ 9 set dwday=0%dwday%
                      SET  Datenow=%dwyear%%dwmonth%%dwday%

                      echo Datenow=%Datenow%

                      Output:

                      C:test> mc.bat
                      dwMONTH=08
                      dwDAY=9
                      dwYEAR=2010
                      Datenow=20100809

                      C:test>

                      When dwDAY is not less than or equal to 9, no zero is added. ( We subtracted -14 not -16 )

                      Output:

                      C:test> mc.bat
                      dwMONTH=08
                      dwDAY=11
                      dwYEAR=2010
                      Datenow=20100811

                      C:test>

                      « Last Edit: August 25, 2010, 11:41:52 AM by Fields »
                      Member of the Human Race; Citizen of the World.

                      Fields



                        Beginner

                        Thanked: 3
                        Re: Help with script involving dates and days of week
                        « Reply #12 on: August 25, 2010, 12:17:56 PM »


                        I tried your code but it placed a zero in front all dates even if there were already 2 digits.  But I like your logic here.  Im trying this but it isnt working quite right either. Any thoughts?


                        set /?
                        « Sent to: mcgriff1969 on: Today at 12:14:03 PM »     

                        --------------------------------------------------------------------------------

                         set dwday=0%dwday%

                         set /a dwday=0%dwday%

                        set /a  will not  work 09 is octal not an integer
                        Member of the Human Race; Citizen of the World.

                        Salmon Trout

                        • Guest
                        Re: Help with script involving dates and days of week
                        « Reply #13 on: August 25, 2010, 12:19:11 PM »
                        09 is octal not an integer

                        09 is not octal, and it is an integer.

                        mcgriff1969

                          Topic Starter


                          Rookie

                          Re: Help with script involving dates and days of week
                          « Reply #14 on: August 25, 2010, 03:02:16 PM »
                          C:test>Display  mc.bat

                          @echo off
                          SET dwMONTH=%DATE:~4,2%
                          echo dwMONTH=%dwMONTH%
                          SET /A dwDAY=%DATE:~7,2%-16
                          echo dwDAY=%dwDAY%
                          SET dwYEAR=%DATE:~10,4%
                          echo dwYEAR=%dwYEAR%
                          if %dwday% LEQ 9 set dwday=0%dwday%
                          SET  Datenow=%dwyear%%dwmonth%%dwday%



                          I think you've got it! :)

                          Salmon Trout

                          • Guest
                          Re: Help with script involving dates and days of week
                          « Reply #15 on: August 25, 2010, 03:27:43 PM »

                          usual rubbish


                          Why is he still here?

                          Fields



                            Beginner

                            Thanked: 3
                            Help with script involving dates and days of week
                            « Reply #16 on: August 25, 2010, 04:17:43 PM »

                            I think we  got it!

                            C:test>Display  mc.bat

                            @echo off
                            SET dwMONTH=%DATE:~4,2%
                            echo dwMONTH=%dwMONTH%
                            SET /A dwDAY=%DATE:~7,2%-16
                            echo dwDAY=%dwDAY%
                            SET dwYEAR=%DATE:~10,4%
                            echo dwYEAR=%dwYEAR%
                            if %dwday% LEQ 9 set dwday=0%dwday%
                            SET  Datenow=%dwyear%%dwmonth%%dwday%

                            QED

                            __________________

                            Post your complete code.

                            Im not sure about your other two questions?

                            When I back up against another month it fails also?

                            Can this be fixed?  Also can the day of the week that corresponds to the date be returned as a variable?

                            Day of week as a variable is already furnished:

                            Datenow is a variable.

                            « Last Edit: August 25, 2010, 04:37:31 PM by Fields »
                            Member of the Human Race; Citizen of the World.

                            ghostdog74



                              Specialist

                              Thanked: 27
                              Re: Help with script involving dates and days of week
                              « Reply #17 on: August 25, 2010, 05:39:09 PM »
                              Many suggestions from the Ghost and Helpless about what does not work.

                              But no suggestions or examples from the Ghost and Helpless of what can be done.

                              The Cat Bell?
                              better than giving wrong examples that cannot work, as you always did.
                              My help is always the same regarding dates. Either use vbscript or totally forget about batch. Use a real programming language.

                              Fields



                                Beginner

                                Thanked: 3
                                Re: Help with script involving dates and days of week
                                « Reply #18 on: August 25, 2010, 06:41:56 PM »

                                 When I back up against another month it fails also.


                                The VBS/batch  works best for me.  Im still learning VBS.


                                C:test>display  backday.bat

                                @echo off
                                CScript //nologo  backday.vbs  > back.txt

                                set /p back=<back.txt
                                set back=%back:~0,9%


                                echo Back Date=%back%

                                echo From Now -35 days

                                Output:

                                C:test> backday.bat
                                Back Date=7/21/2010
                                From Now -35 days

                                C:test>Display   backday.vbs
                                Wscript.Echo Now -35

                                _________________________
                                The Date Now is:
                                 Wed 08/25/2010

                                « Last Edit: August 25, 2010, 06:59:18 PM by Fields »
                                Member of the Human Race; Citizen of the World.

                                Fields



                                  Beginner

                                  Thanked: 3
                                  Help with script involving dates and days of week
                                  « Reply #19 on: August 25, 2010, 09:01:32 PM »


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


                                  The following will find the day of the week for Now -35 days. The -35 should be a command line argument. But Im new to VBS and do not know how to pass an argument from the command line to the vbs script. I shall find the answer.

                                  C:test>display  day.bat

                                  @echo off
                                  rem Wscript.Echo WeekdayName(Weekday(Now -35))

                                  cscript //nologo  day.vbs  > weekday.txt

                                  set /p weekday=<weekday.txt

                                  set weekday=%weekday:~0,3%

                                  echo weekday=%weekday%

                                  echo when Now -35 days

                                  Output:

                                  C:test>day.bat
                                  weekday=Wed
                                  when Now -35 days

                                  C:test>
                                  Member of the Human Race; Citizen of the World.

                                  Dusty



                                    Egghead

                                  • I could if she would, but she won't so I don't.
                                  • Thanked: 75
                                  • Experience: Beginner
                                  • OS: Windows XP
                                  Re: Help with script involving dates and days of week
                                  « Reply #20 on: August 25, 2010, 11:37:27 PM »
                                  Perhaps this will help ???

                                  One good deed is worth more than a year of good intentions.

                                  Salmon Trout

                                  • Guest
                                  Re: Help with script involving dates and days of week
                                  « Reply #21 on: August 25, 2010, 11:52:31 PM »
                                  But Im new to VBS and do not know how to pass an argument from the command line to the vbs script. I shall find the answer.

                                  Study the numerous scripts you steal from other posters (mainly me).

                                  Fields



                                    Beginner

                                    Thanked: 3
                                    Help with script involving dates and days of week
                                    « Reply #22 on: August 26, 2010, 07:32:25 AM »
                                    Study the numerous scripts you steal from other posters (mainly me).


                                    The ST examples are the worst of all.  The attempt by ST  is to make VBS more complicated than it is.  The VBS functions do all the work, we simply supply needed arguments. There are many good examples on the internet.
                                    Member of the Human Race; Citizen of the World.

                                    Fields



                                      Beginner

                                      Thanked: 3
                                      Help with script involving dates and days of week
                                      « Reply #23 on: August 26, 2010, 12:01:37 PM »
                                      When I back up against another month it fails also.

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


                                      Find date last month and the weekday name with one script.


                                      C:test>display  dayback.bat

                                      @echo off
                                      rem backday.vbs
                                      rem Wscript.Echo Now -35
                                      CScript //nologo  backday.vbs  > back.txt
                                      set /p back=<back.txt
                                      set back=%back:~0,9%

                                      echo Back Date=%back%
                                      echo From Now -35 days

                                      rem Wscript.Echo WeekdayName(Weekday(Now -35))

                                      cscript //nologo  day.vbs  > weekday.txt

                                      set /p weekday=<weekday.txt

                                      set weekday=%weekday:~0,3%

                                      echo weekday=%weekday%

                                      echo when Now -35 days

                                      Output:

                                      C:test>dayback.bat
                                      Back Date=7/22/2010
                                      From Now -35 days
                                      weekday=Thu
                                      when Now -35 days

                                      C:test>
                                      Member of the Human Race; Citizen of the World.

                                      Salmon Trout

                                      • Guest
                                      Re: Help with script involving dates and days of week
                                      « Reply #24 on: August 26, 2010, 12:16:38 PM »
                                      I don't think anyone is reading this thread now, except for the masochists, and all your different login "names", Bill.

                                      Fields



                                        Beginner

                                        Thanked: 3
                                        Help with script involving dates and days of week
                                        « Reply #25 on: August 26, 2010, 02:11:10 PM »
                                        I dont think anyone is reading this thread now, except for the masochists, and all their different login names.


                                        This is excellent thread with excellent solutions.

                                        And all ST can say are his usual negative comments.



                                        Member of the Human Race; Citizen of the World.

                                        Salmon Trout

                                        • Guest
                                        Re: Help with script involving dates and days of week
                                        « Reply #26 on: August 26, 2010, 02:15:09 PM »

                                        And all ST can say is his usual negative comments.


                                        are his usual negative comments


                                        BC_Programmer


                                          Mastermind
                                        • Typing is no substitute for thinking.
                                        • Thanked: 1140
                                          • Yes
                                          • Yes
                                          • BC-Programming.com
                                        • Certifications: List
                                        • Computer: Specs
                                        • Experience: Beginner
                                        • OS: Windows 11
                                        Re: Help with script involving dates and days of week
                                        « Reply #27 on: August 26, 2010, 02:31:17 PM »
                                        Quote
                                        This is excellent thread with excellent solutions.

                                        I was trying to dereference Null Pointers before it was cool.

                                        Fields



                                          Beginner

                                          Thanked: 3
                                          Help with script involving dates and days of week
                                          « Reply #28 on: August 26, 2010, 05:18:22 PM »

                                           When I back up against another month it fails also.

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

                                          The batch/vbs will accept any date (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
                                          « Last Edit: August 26, 2010, 05:54:56 PM by Fields »
                                          Member of the Human Race; Citizen of the World.

                                          Salmon Trout

                                          • Guest
                                          Re: Help with script involving dates and days of week
                                          « Reply #29 on: August 27, 2010, 01:00:04 PM »
                                                                      ___________________________
                                                             /|  /|  |                          |
                                                             ||__||  |       Please don't       |
                                                            /   O O\__           feed           |
                                                           /          \       the troll         |
                                                          /      \     \                        |
                                                         /   _    \     \ ----------------------
                                                        /    |\____\     \     ||               
                                                       /     | | | |\____/     ||               
                                                      /       \|_|_|/   |    __||               
                                                     /  /  \            |____| ||               
                                                    /   |   | /|        |      --|               
                                                    |   |   |//         |____  --|               
                                             * _    |  |_|_|_|          |     \-/               
                                          *-- _--\ _ \     //           |                       
                                            /  _     \\ _ //   |        /                       
                                          *  /   \_ /- | -     |       |                         
                                            *      ___ c_c_c_C/ \C_c_c_c____________             

                                          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.