1.    15 Jan 2016 #1
    Join Date : Jul 2015
    Posts : 127
    Windows 10

    How to output day of week to variable in batch

    Hi all,

    I am trying to write a batch file in Windows 10 to output day of week (Monday, Tuesday etc) to variable do that I can do certain procedures on differnt days o the week and am having major problems.

    If I type DATE /T at command prompt I get 15/01/16 and no day of week.

    I have change regional setting so that long date is in correct format but still if I type DATE /T at command prompt I get 15/01/16 and no day of week.

    All help appreciated.

    Thank you.
      My System SpecsSystem Spec

  2.    15 Jan 2016 #2
    Join Date : Oct 2013
    A Finnish ex-pat in Germany
    Posts : 8,683
    Windows 10 Pro

    DATE /T shows the date, not day of the week. You need WMIC command to get the day of the week:

    wmic path win32_localtime get dayofweek

    Click image for larger version. 

Name:	2016_01_15_20_27_231.png 
Views:	17 
Size:	20.0 KB 
ID:	58993

    The output will be a number from 1 to 7, 1 being either Sunday or Monday depending on what is your local setting, if the first day of the week is Sunday or Monday. In my case, European system and Monday as the first day of the week, the command shown in above screenshot (yellow highlight) gave just now the output (green highlight) as 5 (Friday).

      My System SpecsSystem Spec


Similar Threads
Thread Forum
Solved Writhing Batch File
Here is my batch file but it will not delete the file? Must be missing something :( del "C:\Users\Larry\AppData\Local\TractorParts\tractor\ConfigSetting" Trying to delete the ConfigSetting File
General Support
App doesnt open through a batch file
Chaps... I have a desktop running with a few apps 24/7 feeding to a network, on the rare occasion it drops or restarts due to some update or power outage I thought I could write a simple batchfile just to restart everything automatically. ...
Software and Apps
Start a program from a batch file
I'm trying to create a batch file that should - call another batch file - start a program and then wait for the program to close - call another batch file My goal with this is to work around an issue in Windows 10 where the screensaver won't...
Software and Apps
System Info Batch File
Hi Everyone, I thought it may be interesting to get input from others regarding this batch file. I was hoping for suggestions about: Information to add to the report. Ways of making the current code more efficient. Etc... A while back i...
Chillout Room
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd
All times are GMT -5. The time now is 04:10.
Find Us
Twitter Facebook Google+

Windows 10 Forums