1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

DATE /T

Discussion in 'Support' started by JohnQSmith, May 24, 2012.

  1. JohnQSmith

    Joined:
    Jan 19, 2011
    Messages:
    564
    Likes Received:
    8
    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?
     
  2. JohnQSmith

    Joined:
    Jan 19, 2011
    Messages:
    564
    Likes Received:
    8
    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
     
  3. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,883
    Likes Received:
    29
    I see a different difference. :-)

    Code:
    TCC:
    v:\> date /t
    Thu 2012-05-24
     
    CMD:
    C:\Users\vefatica> date /t
    2012-05-24
     
  4. JohnQSmith

    Joined:
    Jan 19, 2011
    Messages:
    564
    Likes Received:
    8
    Hmm... gonna hafta look at my localization settings although I think a specific machine's output should be the same.
     
  5. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,804
    Likes Received:
    82
    Yes. Because TCC is emulating 4DOS's behavior, which had the option before CMD.

    It could probably be changed now that most user's don't expect backwards compatibility with 4DOS.
     
  6. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,804
    Likes Received:
    82
    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.
     

Share This Page