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
Windows BatchMicrosoft DOS

Avatar of undefined
Last Comment
BillDL

8/22/2022 - Mon
Farhan Kazi

Check following batch script.

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

Open in new window

ASKER
towo2002

Hi Farhan,

Sorry about that it returns "ed" after running the script, please kindly advise
devil_himself

open command prompt and type

echo %date%

post the results
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER
towo2002

Dear devil,

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


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

Open in new window

ASKER CERTIFIED SOLUTION
BillDL

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
BillDL

Thank you towo2002
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.