1.

Solve : How to read day of the week with dos commands?

Answer»

Hi EVERYONE,

I need to read the day of the week by a DOS command.
commands "time" and "date" don't help me.
With Solaris environment, with command "date" and some options I can read what I want like "Tue" for TUESDAY or "Feb" for February" ....

I need to do a batch file running on DOS.

Please help me


ThanksDo you mean  MS-DOS or Windows command prompt? If Windows, which version?
I mean windows prompt.
I'm working on windows 2000The native Windows 200 command scripting language (which is not MS-DOS) does not have date functions like you describe, but from a batch file (command script) you can access the ones in Visual Basic Script.

Code: [Select]echo off
REM Create VBS script
set vbsfile=DateInfo.vbs
echo           Newdate = Date>%vbsfile%
echo          DateYear = DatePart("YYYY", Newdate)>>%vbsfile%
echo         DateMonth = DatePart("M"   , Newdate)>>%vbsfile%
echo           DateDay = DatePart("D"   , Newdate)>>%vbsfile%
echo        WeekOfYear = DatePart("WW"  , Newdate)>>%vbsfile%
echo         DayOfYear = DatePart("Y"   , Newdate)>>%vbsfile%
echo     WeekDayNumber = DatePart("W"   , Newdate)>>%vbsfile%
echo    TodayNameShort = WeekdayName(WeekDayNumber,True)>>%vbsfile%
echo     TodayNameFull = WeekdayName(WeekDayNumber,False)>>%vbsfile%
echo    MonthNameShort = MONTHNAME(DateMonth,True)>>%vbsfile%
echo     MonthNameLong = MonthName(DateMonth,False)>>%vbsfile%
echo    Wscript.Echo DateYear^&" "^&DateMonth^&" "^&DateDay^&" "^&Week^
OfYear^&" "^&DayOfYear^&" "^&WeekDayNumber^&" "^&Today^
NameShort^&" "^&TodayNameFull^&" "^&MonthNameShort^&" "^&MonthNameLong>>%vbsfile%

REM    Store output of vbs script in variables
for /f "tokens=1-10 DELIMS= " %%A in ( ' cscript //nologo %vbsfile% ' ) do (
set Year=%%A
set Month=%%B
set Day=%%C
set WeekNumber=%%D
set DayNumber=%%E
set DayOfWeekNum=%%F
set DayNameShort=%%G
set DayNameLong=%%H
set MonthNameShort=%%I
set MonthNameLong=%%J
)

REM 3) Do something with the data
echo.
echo Date Year                 : %Year%
echo Date Month                : %Month%
echo Date Day                  : %Day%
echo Week Of Year              : %WeekNumber%
echo Day Of Year               : %DayNumber%
echo Day Of Week [Number]      : %DayOfWeekNum%
echo Day Of Week [Short Name]  : %DayNameShort%
echo Day Of Week [Full Name]   : %DayNameLong%
echo Month [Short Name]        : %MonthNameShort%
echo Month [Long Name]         : %MonthNameLong%
echo.
Echo %DayNameLong%, %MonthNameLong% %Day%, %Year% is in week %WeekNumber%
echo.







Thaks but I solved in this way:

http://www.flyonthenet.com/articoli/sistemi-windows/giorno-settimana-odierno-script-batch.html

I hope you can understand italian.

Thanks a lotYou changed a registry setting so that your local date format includes the short name of the day of the week?

Quote

I hope you can understand italian.

Va bene!


Discussion

No Comment Found