Computing.Net > Forums > Programming > Batch Files - Reformatting Date

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch Files - Reformatting Date

Reply to Message Icon

Name: tomp
Date: June 12, 2007 at 12:50:03 Pacific
OS: XP
CPU/Ram: 2gb
Product: homemade
Comment:

I started this thread over to keep from confusing anyone.

I want to create a simple batch file routine to change the date fields within a string of data in a .csv file. The current date is formatted as yyyy-mm-dd and I want to change it to mm-dd-yyyy.
There are multiple records within this .csv file and each one has a date field that needs to be converted.

Any help would be appreciated.

Tom P



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: June 13, 2007 at 02:25:11 Pacific
Reply:

see lucky #13

http://computing.net/programming/ww...



=====================================
If at first you don't succeed, you're about average.

M2



0

Response Number 2
Name: ghostdog
Date: June 13, 2007 at 07:57:36 Pacific
Reply:

assuming its csv like this
someword,2006-12-12,end
anotherword,2006-12-13,blah
if you know vbscript, here's a snippet
[code]
Set FSO = CreateObject("Scripting.FileSystemObject")
Const ForReading = 1
Set MyFile = FSO.OpenTextFile("C:\file.csv",ForReading)
Do Until MyFile.AtEndOfStream
strNextLine = MyFile.Readline
arrcsv = Split(strNextLine , ",")
MyDate = Split(arrcsv(1),"-")
arrcsv(1) = MyDate(1) &"-"& MyDate(2) &"-"& Mydate(0)
WScript.Echo Join(arrcsv,",")
Loop
[/code]
on command line:
cscript myscript.vbs > outfile
your input file will look different, so tweak to your needs.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Ping 6 ip's and e-mail me... Ping Config - blog



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch Files - Reformatting Date

batch file name date and time www.computing.net/answers/programming/batch-file-name-date-and-time/15060.html

batch file:Insert date in file www.computing.net/answers/programming/batch-fileinsert-date-in-file/11123.html

Batch File- Current Date in Excel www.computing.net/answers/programming/batch-file-current-date-in-excel/16735.html