アプリ版:「スタンプのみでお礼する」機能のリリースについて

バッチファイル(.BAT)をWindows2000Serverで実行する際、パラメータ付きで実行します。

2000Serverの1日前の日付をパラメータにしたいのですが可能でしょうか?(昨日のデータを抽出する)

以上、お願いいたします。

A 回答 (1件)

とりあえず作ってみました。


これで前日の日付は取得できるはずです。
ただし、うるう年とか2000年問題には対応してません。
あと詳細なデバッグはやってませんのでエラーがあるかもしれません。

for /f "tokens=1 delims=/ " %%i in ('date /t') do set year=%%i
for /f "tokens=2 delims=/ " %%j in ('date /t') do set month=%%j
for /f "tokens=3 delims=/ " %%k in ('date /t') do set day=%%k

echo %year%
echo %month%
echo %day%

if %month%==01 goto jan
goto aaa

:jan
if %day%==01 goto gantan
set /a day=%day%-1
goto last

:gantan
set /a year=%year%-1
set month=12
set day=31
goto last

:aaa
if %day%==01 goto tuitati
set /a day=%day%-1
goto last

:tuitati
if %month%==02 goto feb
if %month%==03 goto mar
if %month%==04 goto spr
if %month%==05 goto may
if %month%==06 goto jun
if %month%==07 goto jul
if %month%==08 goto aug
if %month%==09 goto sep
if %month%==10 goto oct
if %month%==11 goto nov
if %month%==12 goto dec
goto last

:feb
set month=1
set day=31
goto last

:mar
set month=2
set day=28
goto last

:spr
set month=3
set day=31
goto last

:may
set month=4
set day=30

:jun
set month=5
set day=31
goto last

:jul
set month=6
set day=30
goto last

:aug
set month=7
set day=31
goto last

:sep
set month=8
set day=31
goto last

:oct
set month=9
set day=30
goto last

:nov
set month=10
set day=31
goto last

:dec
set month=11
set day=30
goto last

:last
set hizuke=%year%%month%%day%
echo %hizuke%

pause
    • good
    • 0
この回答へのお礼

ありがとうございます。
こちらでテストしてみます。

お礼日時:2002/11/14 09:13

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!