DATE /T

Jan 19, 2011
604
14
Norman, OK
I have a BATCH file that in CMD parses the DATE /T command to create some variables which are used to create directories.
Code:
for /f "tokens=2-4 delims=/ " %%a in ('date /t') do (
set temp_today=%%b
set temp_fulldate=%%c%%a%%b
)
I checked the directory where the new directories are created and noticed that today's directory was missing. I then realized that I had run the batch in TCC instead of CMD. I found the new directory, but it was not named what it should have been. Come to find out, the DATE command in CMD creates different output than the DATE command in TCC.
Code:
cmd> date /t
Thu 05/24/2012
Code:
tcc> date /t
Thu  5/24/2012
Is this intentional? If so, why when compatibility with CMD is usually paramount?
 
Jan 19, 2011
604
14
Norman, OK
I found another DATE output discrepancy; this time with the built in variable. The first command of each example just shows that the variable is not previously set.
Code:
cmd> set date
Environment variable date not defined
 
cmd> echo %date%
Thu 05/24/2012
Code:
tcc> set date
TCC: Not in environment "date*"
 
tcc> echo %date
5/24/2012
 
May 20, 2008
11,378
98
Syracuse, NY, USA
I see a different difference. :-)

Code:
TCC:
v:\> date /t
Thu 2012-05-24
 
CMD:
C:\Users\vefatica> date /t
2012-05-24
 
Jan 19, 2011
604
14
Norman, OK
I see a different difference. :)
Hmm... gonna hafta look at my localization settings although I think a specific machine's output should be the same.
 

rconn

Administrator
Staff member
May 14, 2008
12,340
149
I found another DATE output discrepancy; this time with the built in variable.

The TCC output is consistent across machines; the CMD output will vary (wildly). IMHO when creating batch files it's more important to have widespread consistency instead of CMD's random variable output.

But the %DATE% variable is about the worst one you could use for anything requiring consistency.
 
Nov 11, 2017
4
0
And five years later this STILL isn't fixed.

How can I get the correct format when under TCC?
 

rps

Jul 6, 2008
436
6
And five years later this STILL isn't fixed.

How can I get the correct format when under TCC?
Have you tried?
Code:
v21.01.58
$date /f2 /t
Sat 11/11/2017
In Windows 10
Code:
C:\Users\rps>echo %date%
Sat 11/11/2017
Works even in v17
Code:
v17.00.77
$date /f2 /t
Sat 11/11/2017
Maybe I lost the OPs' objective, but it seems there is a method to get a CMD version of date from TCC and it works back to TCC v17.00.77.
 
Nov 11, 2017
4
0
@rps, not so good for cmd files. I wound up branching... if [%TCMD%]==[] goto DOS
and handling them separately.

Joe, great tip. Needs better search indexing. But I'm not convinced. From a TCC prompt...

[]date
Sat 11/11/2017 17:27:58
New date (mm-dd-[yy]yy):

[]echo %date%
11/11/2017

Do you see an inconsistency here?
 


Interesting.

When I run this under CMD 64-bit and CMD 32-bit, I get;
Code:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

c:\utils>echo %date%
Sat 11/11/2017

When I disable internal TCC Date, I get the same thing that you did;
Code:
c:\users\jlc\utils>ver /r & which date & echo %date%

TCC  18.00.32 x64   Windows 7 [Version 6.1.7601]
TCC Build 32   Windows 7 Build 7601  Service Pack 1
Registered to Joe Caverly - 1 System License
date is an unknown command
11/11/2017

So, Rex's posts in #5 and #6 above, must be the reason.

What about this alias?
Code:
alias date=cmd /c date %$

...and/or
Code:
set date=`%@exec[cmd /c date /t]`

...which returns
Code:
echo %date%
Sat 11/11/2017
0

...and how do I get rid of that 0?

Joe
 
Similar threads
Thread starter Title Forum Replies Date
sully9 How to? Unexpected %DATE% CMD variable format (vs DATE /T format) in CMDebug Support 1
mfarah Fixed The DATE command produces the wrong error message. Support 1
T Date format date different from cmd Support 7
Jesse Heines How to? How to display picture creation date with dir command Support 6
Jesse Heines "Taken" date for JPG and PNG files Support 4
Joe Caverly DATE format 4 Support 7
fpefpe touch - date format Support 2
C 7zip with date range .vs. filelist created with dir and daterange Support 0
C How to? Add date/time to custom tpipe based BTM Support 1
vefatica Download center not up to date Support 4
Joe Caverly How to? Date Range in command line for 7zip /= Support 1
N date and cmd compatibility Support 10
rps Functions @year[date] @isowyear[date] help Support 7
S Closing date for V16 suggestions Support 1
A How to? Create a date range based upon creation date Support 2
S How to? Command dialogs vs. size/date/etc. exclusion ranges Support 1
M How to? Effectively "combine" date and time ranges... Support 2
CWBillow Make a folder named Date-Time Support 18
vefatica Do UNTIL DATETIME date time Support 6
S Date range question Support 4
Roedy date range documentation error Support 2
Jay Sage Inconsistency in Date Formats Between @DATE and @MAKEDATE Support 3
dcantor More date-related help items for V11 Support 0
dcantor Help text for Date Formats Support 0
dcantor Suggestion for @DATE[] input Support 2
dcantor @DATE help example Support 0
CWBillow Date and Time in names Support 11

Similar threads