Page 1 of 1

Changing date format of text file column

Posted: 04 Jun 2013 14:24
by camdenl
I have date and time in the first column of a comma delimited text file in this format:

MM/DD/YYYY H:M:S

and am trying to change it to:

YYYY/MM/DD H:M:S

I have been attempting to write a batch file for this, and have come up with this:

for /f "tokens=1-4 delims=/ " %%a in C:\Users\cs\Documents\headcur.csv do (
set "month=%%a"
set "day=%%b"
set "year=%%c"
set "mytime=%%d"
)
set "newtime=%year%/%month%/%day% %mytime%"
echo %newtime%

But nothing happens...

Could anyone point me in the right direction?

Re: Changing date format of text file column

Posted: 04 Jun 2013 15:24
by Aacini
Don't you liked Endoro's answer at this site?

Re: Changing date format of text file column

Posted: 04 Jun 2013 18:49
by Ocalabob
@Aacini
Aacini wrote:Don't you liked Endoro's answer at: <snip>

Good catch Aacini. Looks to me like Endoro is hard at work compiling a solution for the OP on that forum. It would be a shame for someone in this forum to spend a lot of time and effort to duplicate Endoro's work. Endoro is quite capable of problem solving. [/irritated

Re: Changing date format of text file column

Posted: 04 Jun 2013 22:51
by foxidrive
Endoro's code skipped the data - but the OP didn't add the pertinent information for a while.

Even the code I added will modify the top header line too.