Solved

problems with win 2000 bat file using %date%

Posted on 2003-11-28
9
246 Views
Last Modified: 2010-04-14
Hi,

I am running windows 2000 Pro. When I access the command prompt and type the command %date%

I am returned the message: 'Fri' is not recognized as an internal or exteral command, operable programme or batch file

I want to use %date% in a .bat file I am creating to create a files on a daily basis named the current date.

'Fri' obviously relates to today which is a Friday but I do not want the day I just want the date in the format 28-11-03 not Fri 28-11-03.

How can I change the system to stop the Fri being generated which is stopping my .bat file from running.

Many thanks,

Tom Gribbin
<Email address removed by SerCouWisMOD pursuant of http://www.experts-exchange.com/help/mistakes.jsp#2 >
0
Comment
Question by:tomgribbin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
9 Comments
 
LVL 24

Expert Comment

by:shivsa
ID: 9838652
solve this problem by creating a variable named "date" and put the current date into that variable. use this command at the beginning of the batch file:

for /f  "delims==" %%G IN ('date /t') do set date=%%G

now when you'll write %date% (within the batch file you'll recieve the date)
0
 
LVL 33

Expert Comment

by:MikeKane
ID: 9838653
I had a similiar issue.   I use 2 old com files called getmonth.com and getday.com and I create batchfiles that do something like the following:


GETMONTH
IF ERRORLEVEL 1 IF NOT ERRORLEVEL 2 SET MMDD=01
IF ERRORLEVEL 2 IF NOT ERRORLEVEL 3 SET MMDD=02
etc..etc...all the way to 12

then
GETDAY
IF ERRORLEVEL 1 IF NOT ERRORLEVEL 2 SET MMDD=%MMDD%01
IF ERRORLEVEL 2 IF NOT ERRORLEVEL 3 SET MMDD=%MMDD%02
etc...  all the way to 31  

this worked well in NT and 2k.  


0
 
LVL 24

Expert Comment

by:shivsa
ID: 9838659
or like this
FOR /f "tokens=2-4 delims=/ " %%a in ('date /t') do set date=%%a%%b%%c
If you want your date in different format, you can rearrange the variables a, b and c.
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

Author Comment

by:tomgribbin
ID: 9838684
Shivsa,

Thanks for your swift reply. the code for batch file is below. where and how would i inser the variable which you mention? Sorry for being dim - batch file follows:

cd\
copy e:\datamain.xls e:\dailystats\
rename e:\dailystats\datamain.xls e:\dailystats\%date%.xls

Cheers
0
 
LVL 24

Expert Comment

by:shivsa
ID: 9838700
for /f "tokens=1,2,3,4 delims=/ " %%a in ('date /t') do set today=%%b-%%c-%%d
%today% will have the format u asked for.
0
 
LVL 24

Accepted Solution

by:
shivsa earned 125 total points
ID: 9838708
cd\
copy e:\datamain.xls e:\dailystats\
for /f "tokens=1,2,3,4 delims=/ " %%a in ('date /t') do set today=%%b-%%c-%%d
rename e:\dailystats\datamain.xls e:\dailystats\%today%.xls
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
This article will help to fix the below error for MS Exchange server 2010 I. Out Of office not working II. Certificate error "name on the security certificate is invalid or does not match the name of the site" III. Make Internal URLs and External…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question