Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Is NT 2000 Dos Batch Timestamp sysntax different ?
On 9 Oct 2002 17:21:37 -0700, rs_arwar_at_hotmail.com (Rauf Sarwar)
wrote:
>This works on Win2K. Have not tested it on WinNT.
>
>Use %%VAR for batch file. Use %VAR for command line.
>
>For Date_Timestamp
>set time_stamp=.
>FOR /F "tokens=1-3 delims= " %%A in ("%date%_%time%") do set time_stamp=%%B%%C
>FOR /F "tokens=1-3 delims=/" %%A in ("%time_stamp%") do set time_stamp=%%A%%B%%C
>FOR /F "tokens=1-3 delims=:" %%A in ("%time_stamp%") do set time_stamp=%%A%%B%%C
>FOR /F "tokens=1-2 delims=." %%A in ("%time_stamp%") do set time_stamp=%%A%%B
WinNT does not include the %date% or %time% variables here's something that will work under both NT and 2000 All lines should be indented 3 chars...
@echo off&SETLOCAL
:: This will return date into environment vars :: Works on any NT/2K/XP machine independent of regional date settings :: 20 March 2002
FOR /f "tokens=1-4 delims=/-. " %%G IN ('date /t') DO (call :s_fixdate %%G %%H %%I %%J)
goto :s_print_the_date
:s_fixdate
if "%1:~0,1%" GTR "9" shift
FOR /f "skip=1 tokens=2-4 delims=(-)" %%G IN ('echo.^|date') DO (
set %%G=%1&set %%H=%2&set %%I=%3) goto :eof
:s_print_the_date
echo Month:[%mm%] Day:[%dd%] Year:[%yy%]
ENDLOCAL&SET mm=%mm%&SET dd=%dd%&SET yy=%yy%
And to answer the original subject line
Is NT 2000 Dos Batch Timestamp syntax different ? YES the NT command prompt is different to the 2000 command prompt which in turn is *very* different to the DOS operating system.
http://www.ss64.demon.co.uk/ntsyntax/GetDate.txt
-
Simon Sheppard
http://www.ss64.com
-
Received on Thu Oct 10 2002 - 16:01:16 CDT