Trailing blanks in batch file

  • Thread starter Thread starter Ragnar Midtskogen
  • Start date Start date
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/"
 
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)"
 
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.
 
Back
Top