Link to home
Start Free TrialLog in
Avatar of towo2002
towo2002

asked on

How to get specific characters in Windows Batch program?

Dear all experts,

I would like to know is it possible to convert current year to specific variable in a batch file, the format should be YY (i.e 08), please kindly advise
Avatar of Farhan Kazi
Farhan Kazi
Flag of Australia image

Check following batch script.

Hope this help!
Farhan
@ECHO OFF
SET YY=%DATE:~12,2%
ECHO %YY%

Open in new window

Avatar of towo2002
towo2002

ASKER

Hi Farhan,

Sorry about that it returns "ed" after running the script, please kindly advise
open command prompt and type

echo %date%

post the results
Dear devil,

It returns 05/21/2008 Wed.  And I would like to return the year in "YY" format.  (ie.  return 08)

@echo off
set yy=%date:~8,2%
echo %yy%

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of BillDL
BillDL
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you towo2002