Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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

see lucky #13
http://computing.net/programming/ww...
=====================================
If at first you don't succeed, you're about average.M2

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.

![]() |
Ping 6 ip's and e-mail me...
|
Ping Config - blog
|

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