formating a date reversing the ddmmyy

  • Thread starter Jean Pierre Daviau
  • Start date
J

Jean Pierre Daviau

HI everybody,

I would like to transform this: 2009/10/02 into that 02/10/2009
 
P

Pegasus [MVP]

Jean Pierre Daviau said:
HI everybody,

I would like to transform this: 2009/10/02 into that 02/10/2009

Here you go:
@echo off
set d1=2009/10/02
for /F "tokens=1-3 delims=/" %%a in ('echo %d%') do set d2=%%c/%%b/%%a
echo %d1% %d2%
 
A

Al Dunbar

Pegasus said:
Here you go:
@echo off
set d1=2009/10/02
for /F "tokens=1-3 delims=/" %%a in ('echo %d%') do set d2=%%c/%%b/%%a
echo %d1% %d2%

or:

@echo off
(set d1=2009/10/02)
(set d2=%d1:~8)
for /F "tokens=1-3 delims=/" %%a in ('echo %d%') do set d2=%%c/%%b/%%a
echo %d1% %d2%
 
A

Al Dunbar

Pegasus said:
Here you go:
@echo off
set d1=2009/10/02
for /F "tokens=1-3 delims=/" %%a in ('echo %d%') do set d2=%%c/%%b/%%a
echo %d1% %d2%

or:

@echo off
(set d1=2009/10/02)
(set d2=%d1:~8,2%/%d1:~5,2%/%d1:~0,4%)
echo %d1% %d2%

/Al
 

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