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
date
is not reliable because its output depends on locale. There are already tons of ways on SU: How can I get the date in a locale independent format in a batch file?, How to get Locale-independent modification date batch, How to get the Date in a batch file in a predictable format?, Using Date and Times in a batch file to create a file nameDD-MM-YYYY_weekday
,DD-MM-YYYY weekday
andFri2019-05-17
are definitely completely different things