Trailing blanks in batch file

B

billious

I don't usually see problems with spaces... but for this instance, I would
do it differently. Instead of setting the DAY variable through a for
command, why not just reference the %date% variable.

%date:~0,3% (assuming US-EN format).

So,

SET DAY=%date:~0,3%

(which basically says, start at the 0 character of %date% and take the
first 3 only).

-Lee

Because the format of %date% is variable according to locale (sequence of
elements) and user-configuration (length, values and presence of elements)

For instance, on my machine %date:~0,3% returns "17/"
 
L

leew [MVP]

billious said:
Because the format of %date% is variable according to locale (sequence of
elements) and user-configuration (length, values and presence of elements)

For instance, on my machine %date:~0,3% returns "17/"


Fair enough - though that is why I noted "(assuming US-EN format)"
 
B

billious

leew said:
Fair enough - though that is why I noted "(assuming US-EN format)"

Perhaps you meant "default" format.

Even running US-EN, the actual format returned depends on the user's choice
of whether or not to show the day, etc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top