Solved

problems with win 2000 bat file using %date%

Posted on 2003-11-28
9
229 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

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…
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

760 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now