Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Request for TCC Date Command Custom Format Example

Aug
47
2
I must be missing something, as I can't get custom formats to work with the Date command. Reading the help page, I though that putting the format in quotes would change the display, but I am obviously wrong. Here are my tests:
C:\ > date /t "YY-MM-DD"
Sun 24/01/2021
C:\ > date /t "%%A"
Sun 24/01/2021
The /f switch does work:
C:\\ > date /t /f0
Sun Jan 24, 2021
but I can't figure out how to display the date in a custom format. I would bet that I'm misunderstanding the documentation, but I would appreciate if someone could please post an example for me. Thank you in advance.
 
It confused me too; this feature could certainly stand to be better documented. It turns out that you aren't supped to combine the custom format string with any other options:

Code:
C:\>date "%%Y:%%m:%%d [%%a]"
2021:01:24 [Sun]

C:\>

It looks like you can combine it with /U, but for me that gives an incorrect result:

Code:
C:\>date /u "%%c"
1/24/2021 1:12:55 AM

C:\>

The time is correct, but the date should be the 25th.

(I assume you're using the paid version. This feature is not available in TCC/LE.)
 
"/U" doesn't do anything for time with a custom format.

Code:
v:\> time "%%T"
20:28:03

v:\> time /u "%%T"
20:28:04
 
Code:
C:\>date "%%T"
18:57:17

C:\>date /u "%%T"
01:57:19

C:\>time "%%T"
18:57:24

C:\>time /u "%%T"
18:57:31

C:\>

It does something in DATE. Maybe not the Right Thing, but something.
 
Thank you, Charles. Yes, I have a license for TCC 27.00.16 x64.

Your example is very interesting. But note that the /t switch causes the custom format to be ignored. This isn't mentioned in the documentation.
Code:
C:\\ > date "%%A"
Sunday

C:\\ > date /t "%%A"
Sun 24/01/2021
I don't think that the /u switch gives the incorrect time. On my system here outside of Boston, MA and therefore in EST, /u gives the correct time in GMT. But notice that if I use both /t and /u, the time is not displayed.
Code:
C:\\ > date
Sun 24/01/2021  21:01:08
New date (mm-dd-[yy]yy):

C:\\ > date /u
Mon 25/01/2021  02:01:12
New date (mm-dd-[yy]yy):

C:\\ > date /t /u
Mon 25/01/2021
Thus, the /t switch seems to have more consequences than just suppressing the prompt for a new date. Is that a bug? If not, I believe that the documentation for the Date command needs to be updated.

Thank you again for your help.
 

Similar threads

Back
Top