Subject: | DBI::SQL_TYPE_TIMESTAMP (adTimestamp) insertion erroneous |
Date: | Wed, 12 Dec 2012 16:46:12 +0100 |
To: | bug-DBD-ADO [...] rt.cpan.org |
From: | "Günter Merz" <lotan_rm [...] gmx.de> |
I have the following problem using DBI/DBD::ADO:
I'm trying to insert a date into a column of type DBI::SQL_TYPE_TIMESTAMP using a string of the following format: "YYYY-MM-DD hh:mm:ss".
When I do this, I've observed that there seems to be a logic somewhere that when the day is outside of the month range [1 .. 12] the insertion is correct. However, when the day is within the month range, month and day get swapped---the insertion is incorrect. To work around this problem, I'm currently using this code:
if ($day > 12) {
$field = "$year-$month-$day $hour:$minute:$second";
}
else {
$field = "$year-$day-$month $hour:$minute:$second";
}
This is illogical and makes a move to da different DBD needlessly hard.
I don't know if it is DBD::ADOs problem. When I looked at the code (ADO.pm, _assign_code, line 1153), I didn't see how it could be. On the other hand, I can't imagine that ADO timestamp handling is incorrect in general.
I also wondered if this has to do with NLS. I tried using different locales but couldn't solve the problem this way.
My last try was using a OLE Variant created from a named month (to avoid confusion) instead of a timestamp string:
$field = Win32::OLE::Variant->new(Win32::OLE::Variant::VT_DATE, "August 5, 2012 12:01:00");
But that didn't help either.