How To Find The Day Of The Week In A Batch File (Command Prompt)

IT Support Forum Forums Development General Discussion How To Find The Day Of The Week In A Batch File (Command Prompt)

Viewing 0 reply threads
  • Author
    Posts
    • #2419
      Webmaster
      Keymaster

      The following command can be used in the command prompt or batch file to find the day of the week and then do a check against that day to do another command:

      for /F “tokens=1” %i in (‘date /T’) do @echo %i

      You can then check if the day matches using an IF statement, such as the example below, which does something if the day is Friday:

      for /F “tokens=1” %i in (‘date /T’) do @echo %i

      IF %i=Fri(
      goto FRIDAY)
      ELSE(
      goto ANOTHERDAY)

      :FRIDAY
      :ANOTHERDAY

Viewing 0 reply threads
  • You must be logged in to reply to this topic.