Welcome!

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

SignUp Now!

@DATEFMT Function Problems

Aug
47
2
I am trying to use the @DATEFMT function to simply print Saturday, December 25, 2021. Please see the problems below.
Code:
D:\Work\ > ver

TCC  28.02.18 x64   Windows 10 [Version 10.0.19042.1415]

D:\Work\ > date
Sat 25/12/2021  11:28:16
New date (mm-dd-[yy]yy):

D:\Work\ > echo %@datefmt[%@date[%_date],%%A]
Sunday

D:\Work\ > echo %@datefmt[%@date[%_date],%%B]
TCC: (Sys) The parameter is incorrect.
 "%@datefmt[15334,%B]"

D:\Work\ > echo %@datefmt[%@date[%_date],%%C]
TCC: (Sys) The parameter is incorrect.
 "%@datefmt[15334,%C]"

I get similar errors for all the other codes in the @DATEFMT documentation that I tried. It seems very weird that %%A works (although it returns the wrong day of the week), but not %%B or %%C. Is this a bug? Or am I misunderstanding how to use @DATEFMT.

Thank you,
Jesse Heines
 
I don't think @DATEFMT accepts the format that @DATE returns (the number of days since January 1, 1980 ). This works pretty well.

Code:
v:\> echo %@datefmt[%_date,%%A, %%B %%d, %%Y]
Saturday, December 25, 2021
 
@vefatica

The result with your example here is:

Code:
ADM: N | Zeit: 18:09 | $ echo %@datefmt[%_date,%%A, %%B %%d, %%Y]
Sonntag, Dezember 21, 0025


@"BOTH"

Just a very short analyzing ...

I think it's because the "date" within @datefmt is in yyyy-mm-dd hh:mm:ss format. And my system (and problably system of Jesse) is not configured this way:

Code:
ADM: N | Zeit: 18:10 | $ echo %_date
25.12.21

So if I manually take the date like this:

Code:
ADM: N | Zeit: 18:16 | $ echo %@DATEFMT[2021.12.25,%%A]
Samstag

it works.
 
If you just want today's date, you can use an asterisk:
Code:
C:\>echo %@datefmt[*,%%A]
Saturday

C:\>
 
I don't think @DATEFMT accepts the format that @DATE returns (the number of days since January 1, 1980 ). This works pretty well.

Code:
v:\> echo %@datefmt[%_date,%%A, %%B %%d, %%Y]
Saturday, December 25, 2021
I tried that. Here is the result that I get:

Code:
E:\Work\ > echo %@datefmt[%_date,%%A, %%B %%d, %%Y]
TCC: (Sys) The parameter is incorrect.
 "%@datefmt[%_date,%%A, %%B %%d, %%Y]"

I am running TCC 28.02.18 x64. What version are you runnig that it works for you and not for me?
 
If you just want today's date, you can use an asterisk:
Code:
C:\>echo %@datefmt[*,%%A]
Saturday

C:\>
Thank you, Charles. That worked, but I don't quite understand why. What does * actually return? Or is it just special to the #DATEFMT function? And Merry Christmas to you and yours.
 
I'm also running 28.02.18 x64.

@DATEFMT expects yyyy-mm-dd (or * for the current date, as @Charles Dye suggested). Your first post suggests that yyyy-mm-dd is not your date format. @DATECONV will convert the default date format to yyyy-mm-dd (option 4). So maybe something like this.

Code:
echo %@datefmt[%@dateconv[%_date,4],...]
 
I'm also running 28.02.18 x64.

@DATEFMT expects yyyy-mm-dd (or * for the current date, as @Charles Dye suggested). Your first post suggests that yyyy-mm-dd is not your date format. @DATECONV will convert the default date format to yyyy-mm-dd (option 4). So maybe something like this.

Code:
echo %@datefmt[%@dateconv[%_date,4],...]
Thanks. This is a very helpful explanation. -- Jesse
 

Similar threads

Back
Top