DOS Command

2007-10-26 6:45 pm
I want to echo a date in YYMMDD format
I got the following command but the result is YYYYMMDD format:
For /F "tokens=2-4 delims=/ " %i in ('date /t') do echo %k%i%j

Could any professionals help????!

回答 (2)

2007-10-26 8:49 pm
✔ 最佳答案
i had answered similar question in:
http://hk.knowledge.yahoo.com/question/?qid=7007050606229

try to use system variable %DATE% to get the current date.

if u want to output date in format YYMMDD, u need to know the default date format.

if the date format is dd/mm/yyyy day ( for example: 26/10/2007 Fri ), try this
echo %date:~8,2%%date:~3,2%%date:~0,2%


if the date format is yyyy/mm/dd day ( for example: 2007/10/26 Fri ), try this
echo %date:~2,2%%date:~5,2%%date:~8,2%

OK?
2007-10-26 6:56 pm
try this:

for /F "tokens=2-4 delims=/ " %%i in ('date /t') do set yyyymmdd=%%k%%i%%j
echo %yyyymmdd%


收錄日期: 2021-04-29 21:34:41
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20071026000051KK00752

檢視 Wayback Machine 備份