Solved

problems with win 2000 bat file using %date%

Posted on 2003-11-28
9
241 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
  • 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

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…
Enabling the Skype for Business Meeting Scheduler in Hybrid OWA
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

679 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