-3

I need to use date /t command and convert the date format to DD-MM-YYYY weekday like (MON/TUE/WED) with all the "-" and "_" as listed I can't find an answer on my question. Could you please help me?

What I've done so far:

@echo on 
D: 
cd D:\Exe\VBS 
color 0b 
set day=-1 
echo >"%temp%\%~n0.vbs" s=DateAdd("d",%day%,now) : d=weekday(s)
echo>>"%temp%\%~n0.vbs" WScript.Echo year(s)^& right(100+month(s),2)^& right(100+day(s),2) 
for /f %%a in ('cscript /nologo "%temp%\%~n0.vbs"') do set "result=%%a" 
del "%temp%\%~n0.vbs" 
set "YYYY=%result:~0,4%" 
set "MM=%result:~4,2%" 
set "DD=%result:~6,2%" 
set "date-yesterday=%yyyy%-%mm%-%dd%" 
echo Yesterday was "%date-yesterday%" 

Required result Fri2019-05-17

4

1 Answer 1

0

Another locale/user settings independent way is to use powershell as a tool.

On cmd line:

@for /f %A in ('powershell -nop -c "get-date -f yyyy-MM-dd_ddd"') do @set "YesterDay=%A"

In a batch file:

@Echo off
for /f %%A in ('
    powershell -nop -c "get-date -f yyyy-MM-dd_ddd"
') do set "YesterDay=%%A"

Your title,text,code and last sentence require different things.

Tweak the -f format string to your liking,
casing is important (lower case mm will be minutes)

2
  • Thankyou for your response its working ..fine now
    – Shaf3067
    Commented May 21, 2019 at 10:10
  • Thanks for feedback. If you find an answer helpful you should consider to accept the answer and/or vote up
    – LotPings
    Commented May 21, 2019 at 10:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .