For example, 20060110
How to determine what day of the week it is based on the above date?
How to determine what day of the week it is based on the above date?
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!
Redtek@sweetmeet.comPosted on: 2007-02-05 20:26
- @ echo off && setlocal
- :: Redtek.2006 bbs.cn-dos.net Query what day of the week a certain year/month/day is
- set /p setDate=Please enter the date to query: (Format: year-month-day)
- :: Backup current date and set new date
- for /f %%i in ('date/t') do set "Current date backup=%%i"
- echo %setDate%|date >nul
- :: Display the queried date and restore the current date to the backup date
- echo. && echo The detailed information of the date you want to query is: %date% ] && echo.
- echo %Current date backup%|date >nul
- Pause
@echo off
for %%n in (week1-日 week2-一 week3-二 week4-三 week5-四 week6-五 week7-六) do set Tmp$=%%n&&call set %%Tmp$:-==%%
:loop
cls
echo.
set input=
set /p input= Please enter the date (format: 2007/1/1):
if not defined input exit
echo.
>tmp.vbs echo wscript.echo weekday(#%input%#)
for /f "tokens=* delims=-" %%i in ('"cscript //nologo tmp.vbs"') do call echo Week %%week%%i%%
del tmp.vbs
echo.
pause
goto loop
@echo off
for %%n in (week1-日 week2-一 week3-二 week4-三 week5-四 week6-五 week7-六) do set Tmp$=%%n&&call set %%Tmp$:-==%%
:loop
cls
echo.
set input=
set /p input= Please enter the date (format: 20070101):
if not defined input exit
echo.
>tmp.vbs echo wscript.echo Weekday(CDate("%input:~0,4%-%input:~4,2%-%input:~6,2%"))
for /f "tokens=* delims=-" %%i in ('"cscript //nologo tmp.vbs"') do call echo Week %%week%%i%%
del tmp.vbs
echo.
pause
goto loop
<script language="vbscript">
<!--
MsgBox Weekday(CDate("2006-01-10")-1)
-->
</script>
Originally posted by 26933062 at 2007-2-8 03:40:
The difference between two dates has been solved. Now the problem is how to determine the day of the week?
// For example, given 2007/02/08/Thursday, how to determine the day of the week 18 days ago?
That is, how to subtract 1 or 2 from the current day of the week..........?
...
@echo off
for %%n in (week1-日 week2-一 week3-二 week4-三 week5-四 week6-五 week7-六) do set Tmp$=%%n&&call set %%Tmp$:-==%%
:loop
cls
echo.
set input=
set week=+0
set /p input= Please enter the date (format: 20070101):
if not defined input exit
set /p week= Please enter the number of days interval (format: +8(-8), default is 0):
echo.
>tmp.vbs echo wscript.echo Weekday(CDate("%input:~0,4%-%input:~4,2%-%input:~6,2%")%week%)
for /f "tokens=* delims=-" %%i in ('"cscript //nologo tmp.vbs"') do call echo Day of the week%%week%%i%%
del tmp.vbs
echo.
pause
goto loop@echo off
:loop
cls
echo.
set input=
set week=+0
set /p input= Please enter the date (format: 20070101):
if not defined input exit
set /p week= Please enter the number of days to interval (format: +8(-8), default is 0):
echo.
>tmp.vbs echo wscript.echo WeekdayName(Weekday(CDate("%input:~0,4%-%input:~4,2%-%input:~6,2%")%week%))
for /f %%i in ('"cscript //nologo tmp.vbs"') do call echo %%i
del tmp.vbs
echo.
pause
goto loop