Celeb Glow
general | March 10, 2026

Windows-10 batchfiles are based on DATE command, how to use on lower Windows versions

I'm working on two (virtual) machines:

  • First is a Windows 10 machine
  • Second is a Windows 7 machine

On both, the short date formats are equal: dd.MM.yyyy
On both, I'm running the same batchfile, based on the DATE command.

I'm having differences in the results, related to the outcome of the DATE command results:

  • On Windows 10 : The current date is: st 22.03.2017
  • On Windows 7 : The current date is: 22.03.2017

As you can see, the difference is due to the presence of the name of today (st is an abbreviation of the Czech word for Wednesday).

The Windows 10 system is the master, so my question: how can I alter the Windows-7 system to include the first two letters of the name of the day?

As tests, I've already tried the following for a short date format:

dd dd.MM.yyyy // this is better, the length of the format is good, but it does not start with the initials of the day's name.
dddd dd.MM.yyyy // this starts with the day's name, but completely, and I only want the first two letters.

Meanwhile I had a further look at the problem: the date format seems to be used on two places:

  1. While working with the DATE commandline command (there I need a format like
    xx dd.MM.yyyy (whatever that xx might be) for further processing
  2. During following echo: for /r %DIRECTORY% %I in ("*.*") do echo %~tfIThe idea is to show a timestamp and the filename, something like:
    22.03.2016 13:50 <filename> (without xx)
5

2 Answers

In windows 7 you must use ddd to have a similar format, which is 3 characters, not 2.

So you can use ddd dd.MM.yyyy. That's the supported format.

A way to get to 2 chars there would be to remove one with a batch file.

4

What a mess, but I believe I've found a solution for the issue:

The point is the following: On Windows 10, even while having a simple date format (like dd.MM.yyyy), the date /T commandline adds the first characters of the day, so we get the following:

date /T
st 22.03.2017

And my collegues have built their batchfiles around the presence of those "st" characters. Running those batchfiles on lower Windows versions gives the mentioned problems.

At the beginning of the batchfiles, I've added the line:

DATE=xx %DATE%

(very childish, I admit)
This makes the batchfiles work on my Windows-7 computer.
In order to make it work on both systems, I just need to add a check on the platform, something like:

set WINDOWS_10=%ver | findstr /C:"Version 10"%
if "WINDOWS_10"=="" ( set DATE=xx %DATE%)

I didn't check it yet on Windows-10 PC, but I believe this will do the trick.

3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy