You are not logged in.

#1 15 Sep 2005 08:13

rik
Member
Registered: 11 Sep 2005
Posts: 1

convert month script

Thius batch should convert a month number into text
so 09 =>sep
 

@echo off
set 01=jan
set 02=feb
set 03=mar
set 04=apr
set 05=may
set 06=jun
set 07=jul
set 08=aug
set 09=sep
set 10=oct
set 11=nov
set 12=dec
set month=%1
call set result=%%%month%%%
echo resulting date is %result%

but when I run it I just get:

resulting date is convmonth9

any ideas?
thx

Offline

#2 15 Sep 2005 20:29

Simon Sheppard
Admin
Registered: 27 Aug 2005
Posts: 1,130
Website

Re: convert month script

The problem is the line
call set result=%%%month%%%
This evaluates as %%09%%
and instead of the variable %09% this is parameter %0 followed by 9
try prefixing all the SET commands with a non-numeric character
e.g.

@echo off
set _01=jan
set _02=feb
set _03=mar
set _04=apr
set _05=may
set _06=jun
set _07=jul
set _08=aug
set _09=sep
set _10=oct
set _11=nov
set _12=dec
set month=_%1
call set result=%%%month%%%
echo resulting date is %result%

Offline

Board footer

Powered by