in reply to Formatting a date

I would recommend the MySQL solution offered by Ven'Tatsu, since my philosophy is to do everything on the DB side that you can get away with. That, and you should make use of the handy functions provided by the MySQL folks, since it gives them warm-fuzzy-feelings when you do.

Since this problem could come up in another context where you would need a perl solution, and everybody else who answered so far used regexen, which I think is unneccesary here, I offer the following:

#!/usr/bin/perl use strict; use warnings; my $date = qq(0406141832); my ($YY, $MM, $DD, $hh, $mm) = unpack("A2 A2 A2 A2 A2", $date); my $formatted = "$MM $DD, $hh:$mm"; print $formatted, $/;

unpack is a nice, straightforward, and fast solution to parsing fixed-width strings like this. Just something to add to your bag-o-tricks.

--
edan