date format

  • Thread starter Thread starter sali
  • Start date Start date
S

sali

"for" command timedate modifier %~ti extracts timedate part of file, but it
returns date in local format, how to get date in ansi format "yyyymmddd"
[which is universal for comparing]?

thnx
 
sali said:
"for" command timedate modifier %~ti extracts timedate part of
file, but it returns date in local format, how to get date in ansi
format "yyyymmddd" [which is universal for comparing]?

You could try setting a fixed codepage for the duration, but no
guarantees. The other, guaranteed, solution is VBS.

Both the methods are covered in
153350 Feb 11 2006 ftp://garbo.uwasa.fi/pc/link/tscmd.zip
tscmd.zip Useful NT/2000/XP script tricks and tips, T.Salmi

All the best, Timo
 
"for" command timedate modifier %~ti extracts timedate part of file, but it
returns date in local format, how to get date in ansi format "yyyymmddd"
[which is universal for comparing]?

thnx
See tip 10210 » Another way to return a 4 digit year, 2 digit month, and 2 digit day from a short date, regardless of your short date format.
in the 'Tips & Tricks' at http://www.jsifaq.com

Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
http://www.jsifaq.com
 
set TheDate=%date%
set Month=%TheDate:~4,2%
set Day=%TheDate:~7,2%
set Year=%TheDate:~10,4%
set DayName=%TheDate:~0,3%
set DateStamp=%Year%%Month%%Day%

The parse function of the set command started in Windows 2000. You can
do the same thing with time for hours,Min,Sec.

Stel
 
Stel said:
set TheDate=%date%
set Month=%TheDate:~4,2%
set Day=%TheDate:~7,2%
set Year=%TheDate:~10,4%
set DayName=%TheDate:~0,3%
set DateStamp=%Year%%Month%%Day%

The parse function of the set command started in Windows 2000. You can
do the same thing with time for hours,Min,Sec.

it is not enough universal! on my system, it exchanged month/days!

one usable trick could be to make:
echo. | date | find "enter" /i
to discover current cp date format [dd-mm-yy] from second line of date
command
 
Back
Top