<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/xhtml; charset=utf-8">
</head>
<body>
<div style="font-family:sans-serif"><div style="white-space:normal">
<p dir="auto">On 13 Dec 2017, at 22:25, Vladimir Melnik wrote:</p>

</div>
<div style="white-space:normal"><blockquote style="border-left:2px solid #777; color:#777; margin:0 0 5px; padding-left:5px"><p dir="auto">I needed to convert `DateTime` objects to an SQL-recognized format (before to give it to the `search()` method), so I'd like to be sure that a `DateTime` object is being deflated according the same algorithm that is being used when I call `update()` or `create()` method.</p>
</blockquote></div>
<div style="white-space:normal">

<p dir="auto">Get the formatter from the DBIC storage engine, and format the date using that:</p>

<pre style="background-color:#F7F7F7; border-radius:5px 5px 5px 5px; margin-left:15px; margin-right:15px; max-width:90vw; overflow-x:auto; padding:5px" bgcolor="#F7F7F7"><code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0" bgcolor="#F7F7F7">my $dt_parser = $schema-&gt;storage-&gt;datetime_parser;
my $date_str = $dt_parser-&gt;format_datetime($dt);
        …-&gt;search({date_col =&gt; $date_str});
</code></pre>

<p dir="auto">Even if you switch to a different db type, the storage engine will always return a parser which handles parsing/formatting dates in correct format.</p>

<p dir="auto">-cng</p>

<p dir="auto">-- </p>

<p dir="auto">Charlie Garrison  <a href="mailto:garrison@zeta.org.au" style="color:#3983C4">garrison@zeta.org.au</a><br>
   github.com/cngarrison   metacpan.org/author/CNG</p>
</div>
</div>
</body>
</html>