Formatting dates (like PHP printf)
Posted: Tue Jun 10, 2008 2:00 pm
Hello
I have a regex which finds dates output from a MS Access database
\t([0-9]+)/([0-9]+)/([0-9]{4})
I want to import it into MySQL so I replace with
\t\3\2\1
But this changes 28/3/2008 into 2008328 where I want 20080328
I've solved the problem by re-exporting from Access, but is there a tidy way I could have added leading zeroes (like I would in PHP by using printf - which, I believe, is an old C function).
Thanks,
Pete
I have a regex which finds dates output from a MS Access database
\t([0-9]+)/([0-9]+)/([0-9]{4})
I want to import it into MySQL so I replace with
\t\3\2\1
But this changes 28/3/2008 into 2008328 where I want 20080328
I've solved the problem by re-exporting from Access, but is there a tidy way I could have added leading zeroes (like I would in PHP by using printf - which, I believe, is an old C function).
Thanks,
Pete