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

Author Topic: how to get next saturday 'Date' in DOS batch file  (Read 26716 times)

0 Members and 1 Guest are viewing this topic.

RoyBailey



    Rookie

    Re: how to get next saturday Date in DOS batch file
    « Reply #30 on: August 17, 2010, 12:57:45 PM »
    RoyBailey, you are one of the most astonishingly stupid imbeciles it has ever been my misfortune to encounter. I see you shirk any discussion of your code. The OP has a choice between: code that works and your lunatic nonsense, which you posted a long while after this very touching message.


    I fear that ComputerHopes effectiveness will be gravely compromised until some method of permanently banning is found.

    ST,

    Thanks for the kind words.

    Some computerhope members would resort to vicious personal attacks.

    The people who use the Computerhope Board can filter the good code from the bad.

    A member who acts as the Final  Judge is not needed.
    « Last Edit: August 17, 2010, 01:11:08 PM by RoyBailey »
    USA

    Salmon Trout

    • Guest
    Re: how to get next saturday \'Date\' in DOS batch file
    « Reply #31 on: August 17, 2010, 01:07:43 PM »

    The people who use the Computerhope Board can filter the good code from the bad.


    They shouldn't have to filter code that works from deliberately posted trolling nonsense.

    RoyBailey



      Rookie

      How to get next saturday Date in DOS batch file
      « Reply #32 on: August 17, 2010, 03:23:08 PM »
      Right now I am able to append the current date by using the below mentioned logic.

      set Pdate=%date:~10,4%%date:~4,2%%date:~7,2%

      Now I want to pass next saturday date in place of current date.


      ( The following code requires no command line arguments or user input. )

      C:test>type   sat3.bat
      @echo off

      set day=%DATE:~0,3%
      echo day=%day%
      if %day%==Sun (
      set /a num=6
      goto  adjust
      )
      if %day%==Mon (
      set /a num=5
      goto adjust
      )
      if %day%==Tue (
      set /a num=4
      goto adjust
      )
      if %day%==Wed (
      set /a num=3
      goto adjust
      )
      if %day%==Thu (
      set /a num=2
      goto adjust
      )
      if %day%==Fri set /a num=1

      :adjust
      set /a SatDate=%DATE:~7,2% +%num%
      echo SatDate=%SatDate%

      set Pdate=%date:~10,4%%date:~4,2%%SatDate%
      echo Pdate=%Pdate%

      Output:

      C:test>sat3.bat
      day=Tue
      SatDate=21
      Pdate=20100821
      C:test>
      USA

      Salmon Trout

      • Guest
      Re: how to get next saturday 'Date' in DOS batch file
      « Reply #33 on: August 17, 2010, 03:31:42 PM »
      (1) echo %date%

      17/08/2010

      No "Tue" around here. So your code breaks. But even in Yankee land...

      (2) Run the code on the 8th or 9th of the month, it'll crash. (You won't understand why)

      (3) Two weeks from today, your code will say that "next Saturday" is August 35th. Nice code, genius! They must be so inbred in your trailer park that the month of August doesn't stop at 31 like it does everywhere else.

      Way past time this dimbulb was banned again.







      RoyBailey



        Rookie

        How to get next saturday Date in DOS batch file
        « Reply #34 on: August 17, 2010, 03:58:17 PM »
        Right now I am able to append the current date by using the below mentioned logic

        set Pdate=%date:~10,4%%date:~4,2%%date:~7,2% {

        Now I want to pass next saturday date in place of current date.

        Zensar,

        The ComputerHope member who is so upset has worked on his Saturday Code for years.

        His code works well.


        I have only worked on the Saturday Code for a day or two.  My code has a few bugs that can be worked
        out.

        My code is strickly batch and in the end will work better.

        Roy
        USA

        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: How to get next saturday Date in DOS batch file
        « Reply #35 on: August 17, 2010, 04:52:52 PM »
        The ComputerHope member who is so upset has worked on his Saturday Code for years.
        I'm not even going to say "I doubt it" Or "probably not" and I'm just going say "that's utter nonsense".

        Quote
        His code works well.
        Yes. It already works.

        Quote
        I have only worked on the Saturday Code for a day or two.  My code has a few bugs that can be worked
        out.
        I doubt you will figure out what they are. And even if you do, the best case scenario is you will have a locale specific implementation. It will never work anywhere the regional settings don't match yours. But of  course only terrorists would dare to vary from the MM/DD/YY format. In fact one might even suppose that the entire concept of different date formats was established in order to circumvent your code working in the future. Clearly a evil terrorist cell has gone back in time and established these silly conventions like DD/MM/YY, because clearly no sane person would ever order the values in increasing order of their magnitude. Nope, it makes far more sense to use the completely abstract MM/DD/YY ordering. Otherwise UPS wins.

        Quote
        My code is strickly batch and in the end will work better.
        Why? How do you know this? As I noted it will not work outside North America, and in fact won't even work in some places there (some people are clearly supporting terrorist groups since they use the DD/MM/YY format)
        I was trying to dereference Null Pointers before it was cool.

        kpac

        • Web moderator


        • Hacker

        • kpac®
        • Thanked: 184
          • Yes
          • Yes
          • Yes
        • Certifications: List
        • Computer: Specs
        • Experience: Expert
        • OS: Windows 7
        Re: how to get next saturday 'Date' in DOS batch file
        « Reply #36 on: August 17, 2010, 04:58:47 PM »
        Bill, wherever you got your "BS.c", I'm not going there.

        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: how to get next saturday 'Date' in DOS batch file
        « Reply #37 on: August 17, 2010, 05:25:23 PM »
        Bill, wherever you got your "BS.c", I'm not going there.

        It was the early 50's. They were different times.

        In some classes the, professor was simply a bear wearing glasses. He didn't like when people would be talking on their lapphones.
        I was trying to dereference Null Pointers before it was cool.

        Salmon Trout

        • Guest
        Re: How to get next saturday Date in DOS batch file
        « Reply #38 on: August 17, 2010, 11:59:09 PM »

        The ComputerHope member who is so upset has worked on his Saturday Code for years.


        About 10 minutes actually.

        Fields



          Beginner

          Thanked: 3
          Re: how to get next saturday Date in DOS batch file
          « Reply #39 on: August 23, 2010, 06:08:08 PM »

          Right now I am able to append the current date by using the below mentioned logic


          Code:

          set Pdate=%date:~10,4%%date:~4,2%%date:~7,2%
          Now I want to pass next saturday date in place of current date.

          http://www.unix.com/windows-dos-issues-discussions/140891-how-get-next-saturdays-date.html

            #1    4 Weeks Ago 
          Zensar 
          Registered User   

          Join Date: Jul 2010
           
          How to get next Saturdays Date?

          --------------------------------------------------------------------------------
          ( Answer from Unix Board)
          @echo off
          >#.vbs echo wsh.echo Set Nextsaturday=^&dateAdd(d,7-Weekday(Date),date)
          for /f delims= %%_ in (cscript /nologo #.vbs) do %%_
          del #.vbs

          set Nextsaturday
          _______________________________________ ___

          Does the above work when next saturday is next month  and/or next year?
          « Last Edit: August 23, 2010, 06:30:54 PM by Fields »
          Member of the Human Race; Citizen of the World.

          Fields



            Beginner

            Thanked: 3
            How to get next saturday Date in DOS batch file
            « Reply #40 on: August 23, 2010, 09:40:41 PM »
            http://www.unix.com/windows-dos-issues-discussions/140891-how-get-next-saturdays-date.html

             
            Does the above work when next saturday is next month?

            The VBS code works when saturday is in the next month.
            Current Date is changed from Current date to Current date + 7  for test.

            Code:
            @echo off
            For /f delims= %%D in (cscript //nologo NextSat.vbs) do (
            set nextsaturday=%%D
            )
            set nextsaturday=%nextsaturday:~0,8%

            echo Next Saturday Is %Nextsaturday%
            echo When Current date + 7

            Output:

            C:> nix.bat
            Next Saturday Is 9/4/2010
            When Current date + 7


            C:>type NextSat.vbs
            CurrentDate=now +7
            wscript.echo FormatDateTime(CurrentDate + (7 - Weekday(CurrentDate)))

            C:>

            Q.E.D


            C:>echo %DATE%
            Mon 08/23/2010

            C:>echo %TIME%
            23:21:39.15

            C:\\\\>
            « Last Edit: August 23, 2010, 10:08:38 PM by Fields »
            Member of the Human Race; Citizen of the World.

            Salmon Trout

            • Guest
            Re: how to get next saturday 'Date' in DOS batch file
            « Reply #41 on: August 23, 2010, 11:51:18 PM »
            Hello again, Bill. In Bill's world, you can get an edited version of my vbs script from a "Unix board".



            Fields



              Beginner

              Thanked: 3
              How to get next saturday Date in DOS batch file
              « Reply #42 on: August 24, 2010, 09:13:52 AM »
              You can get an edited version of my vbs script from a Unix board.

              VBS Script does not belong to Salmon Trout. 

              VBS Script is owned by Microsoft.
              Member of the Human Race; Citizen of the World.

              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: How to get next saturday Date in DOS batch file
              « Reply #43 on: August 24, 2010, 09:30:56 AM »
              VBS Script does not belong to Salmon Trout. 

              VBS Script is owned by Microsoft.

              The script itself, you incontinent turkey faced badger-legged Chinchilla loving Carnal Ostrich visitor, not the interpreter.
              I was trying to dereference Null Pointers before it was cool.

              Salmon Trout

              • Guest
              Re: how to get next saturday 'Date' in DOS batch file
              « Reply #44 on: August 24, 2010, 09:39:08 AM »
              BCP, I think we just fed the troll.