How to output day of week to variable in batch


  1. Posts : 232
    Windows 10
       #1

    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 Computer


  2. Posts : 17,661
    Windows 10 Pro
       #2

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

    Code:
    wmic path win32_localtime get dayofweek

    How to output day of week to variable in batch-2016_01_15_20_27_231.png

    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).

    Kari
      My Computer


 

  Related Discussions
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 18:08.
Find Us




Windows 10 Forums