<?xml version="1.0" encoding="windows-1252"?>
<node id="614228" title="Answer: How do I convert date format between 'DD-MM-YYYY' and 'YYYY-MM-DD' back &amp; forth?" created="2007-05-08 15:36:46" updated="2007-05-08 11:36:46">
<type id="1888">
categorized answer</type>
<author id="11732">
QandAEditors</author>
<data>
<field name="doctext">
Just in case you specify that the date must be in US-style (MM-DD-YYYY), then the above split won't work.

&lt;code&gt;
my $in_date = '11-24-2007'; # or 11/24/2007, or 11.24.2007, or any non-digit-separators
my @parts = split /\D/, $in_date;
my $db_date = join '-', @parts[2, 0, 1];

# to get the original format:
my $sep = '-';
my @parts = split $sep, $db_date;
my $pr_date = join $sep, @parts[1, 2, 0];
print "in: $in_date; db: $db_date; pr: $pr_date\n";
# in: 11-24-2007; db: 2007-11-24; pr: 11-24-2007
&lt;/code&gt;</field>
<field name="parent_node">
614222</field>
</data>
</node>
