Hello,
I just try to concatenate the following variables:
@echo off
FOR /F "tokens=1,2,3 delims=." %%a in ("%date%") do set yy=%%c& set mm=%%b & set dd=%%a
set /a lastyear=%yy%-1
set output=IS_%lastyear%
echo %output%
_________________________
Output:
IS_
Output should be IS_2014
Can somebody help me?
Simple concatenation fails
Moderator: DosItHelp
Re: Simple concatenation fails
Fixed Code:
Output:
Have a look in the %date% variable:
The delimiters here are [space] and Slashes. I used %date: =/% in IN so that the delimiter will only be slashes.
Meerkat
Code: Select all
@echo off
FOR /F "tokens=2,3,4 delims=/" %%a in ("%date: =/%") do set yy=%%c& set mm=%%b & set dd=%%a
set /a lastyear=%yy%-1
set output=IS_%lastyear%
echo %output%
Code: Select all
IS_2014
Have a look in the %date% variable:
Code: Select all
>echo %date%
Wed 12/16/2015
Code: Select all
>echo %date: =/%
Wed/12/16/2015
Meerkat
Re: Simple concatenation fails
This is simpler, but works as well:John A.
Code: Select all
FOR /F "tokens=2,3,4 delims=/ " %%a in ("%date%") do set yy=%%c& set mm=%%b & set dd=%%a
Re: Simple concatenation fails
There are spaces there which will be a problem.