Windows BBS The Place for Microsoft Windows Support! Windows, Support, Help Site

Go Back   Windows BBS > Operating Systems > Windows XP

Windows XP Post your Windows XP related questions here.

Register your FREE account to unlock additional features at WindowsBBS.com
Register
Welcome to WindowsBBS.com
Microsoft Windows Support

Mission Statement

WindowsBBS is an online community dedicated to easily accessible technical support for those using Microsoft operating systems and other Windows software.

Our goal is to become the leading resource for computer users that require assistance with their day-to-day computer usage, including full support for networking PC's, virus & malware removal, system upgrades and general support questions.


Discussion Forums
Operating Systems
Windows 7 Windows 7
Windows Vista Windows Vista
Windows XP Windows XP
Windows Server System Windows Server System
Windows 2000 Windows 2000
Windows 95/98/Me/NT Windows 95/98/Me/NT
Internet & Networking
Networking
Internet Explorer
Microsoft Mail
Firefox, Thunderbird
      & SeaMonkey

General Internet
Security
General Security
Malware and Virus
     Removal

Other
Other Software
Hardware
Test Posts
Community
Introductions
General Discussions
Comments
      & Suggestions

News @ WindowsBBS

Forum Sponsor
 Image

Reply
 
LinkBack Thread Tools
Old 5th July 2007   #1
Geek Member
 
captjlddavis's Avatar
 
Profile:
Join Date: Sep 2002
Location: california
Posts: 550
Computer Experience:
intermediate -
captjlddavis Reputation Levelcaptjlddavis Reputation Level


Batch file date parsing ?

Good day to all.
Problem with date in batch file:
The following is from:
Use the Current Date in a Windows XP Batch File
http://findarticles.com/p/articles/m.../ai_ziff128194

it says:
Quote:
FOR /F "tokens=1-4 delims=/ " %%I IN ('DATE /t') DO SET mydate=%%J%%K%%L

ECHO The value is "%mydate%"

This is strictly for Windows XP and 2000; it won't work on Windows 9x platforms. Note that the middle line is long and maybe word-wrapped in print. It begins with the word FOR and ends with %%L.
..........
DATE /t returns the current date in a form like "Thu 03/25/2004". The tokens= and delims= entries determine how the string will be parsed. Here the delimiters are slash and space, and we have requested tokens 1 through 4. The defined FOR variable %%I gets the first token, which is the day of the week (not used here). The remaining tokens are automatically assigned to the next three letter variables, J, K, and L. By combining them, we get the date in the desired form, such as03252004 .

You can incorporate this command into any batch file—even change the order of the date elements or insert other characters. For example, by ending the line with SET mydate =%%L-%%J-%%K you'd get a sortable yyyy-mm-dd date.
I created a batch file:

jld.bat
FOR /F "tokens=1-4 delims=/ " %%I IN ('DATE /t') DO SET mydate=%%J%%K%%L

ECHO The value is "%mydate%"

It returns "the value is" 042007

Not "07042007"

However if I change the file to read:
FOR /F "tokens=1-4 delims=/ " %%I IN ('DATE /t') DO SET mydate=%%I%%J%%K%%L
I added the "%%I" to the string

it returns the value = "07042007"

I would like the returned value to be:"20070704"

It used to work as I want, but something has changed....the only place that I have dinked around is in CP - region settings, I set time to display 24h clock.

Any insight is gretly appreciated.

captjlddavis is offline   Reply With Quote
Didn't find the information you thought to find?
Check out these Similar Threads
Old 5th July 2007   #2
Geek Member
 
captjlddavis's Avatar
 
Profile:
Join Date: Sep 2002
Location: california
Posts: 550
Computer Experience:
intermediate -
captjlddavis Reputation Levelcaptjlddavis Reputation Level


I think I found the problem.....

Date setting in CP - Regional & language - Customize date
short date format = M/d/yyyy ( works like it is supposed to )
I had MM/dd/yyyy - and it don't work.......

FOR /F "tokens=1-4 delims=/ " %%I IN ('DATE /t') DO SET mydate=%%L%%J%%K

ECHO The value is "%mydate%"

returns:
20070704

sorry for any inconvenience

regards:captjlddavis


Last edited by captjlddavis; 5th July 2007 at 09:17.
captjlddavis is offline   Reply With Quote



Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reinstalling free ZoneAlarm 70.377.000 SkeetF General Security 9 27th June 2007 00:09
Changing the way a File Folder Opens larsonjean Windows XP 3 1st September 2005 17:38
Missing .ssl Files - Firefox? Dreambird Firefox, Thunderbird & SeaMonkey 8 24th March 2005 00:58
Win XP and SFC jabiru Windows XP 18 1st December 2003 21:07


All times are GMT +1. The time now is 08:53.






Advertisements do not imply our endorsement of the product or service advertised.
Powered by vBulletin®
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.5.1
Copyright © 2002 - 2010 WindowsBBS.com. All rights reserved.
Terms of Use, Legal Information & Privacy Policy
[]