in reply to Perl and MySQL update question

You didn't mention which database you are using. In MySQL, the following single SQL update should do the job:
update `table` set `date`=CONCAT(SUBSTR(`date`,7,4), SUBSTR(`date`,4,2 +), SUBSTR(`date`,1,2));
Something similar should be possible in other databases too.

--
Ignorance killed the cat, curiosity was framed.

Replies are listed 'Best First'.
Re^2: Perl and MySQL update question
by polettix (Vicar) on Nov 19, 2007 at 08:53 UTC
    MySQL is implied by the title. Moreover, you're assuming that the date field is a textual one, which could not be the case, and the OP is asking for an int field. andreas1234567's approach seems more robust.

    Flavio
    perl -ple'$_=reverse' <<<ti.xittelop@oivalf

    Io ho capito... ma tu che hai detto?
      Missed the (obvious) MySQL reference in the title, sorry.
      The data in the date field is in the format dd:mm:yyyy, which indicates that it is _not_ a datetime field (so it must be a text field). In this case andreas1234567's approach would not work.

      --
      Ignorance killed the cat, curiosity was framed.
        I was referring to the fact that the target was asked to be of integer type, but I see your point about the source. Probably a merge between your solution and andreas1234567's would do.

        Flavio
        perl -ple'$_=reverse' <<<ti.xittelop@oivalf

        Io ho capito... ma tu che hai detto?