I've done some testing, and some reading in the docs. Now I'll post my speculation.

Date::Manip's DateParse() function, in scalar context, returns a string that looks like yyyymmddhh:mm:ss.

Reading in the docs for MySQL here: http://dev.mysql.com/doc/mysql/en/DATETIME.html... I don't see where the format returned by Date::Manip's DateParse() function is a format recognized by MySQL. You probably need to at least massage the format by removing the colons from the string. At that point MySQL's date field should recognize the format and act appropriately.

Reading further in the documentation for Date::Manip I found this nugget of information:

INTERNAL


When a date is parsed using ParseDate, that date is stored in an internal format which is understood by the Date::Manip routines UnixDate and DateCalc. Originally, the format used to store the date internally was:
YYYYMMDDHH:MN:SS
It has been suggested that I remove the colons (:) to shorten this to:
YYYYMMDDHHMNSS
The main advantage of this is that some databases are colon delimited which makes storing a date from Date::Manip tedious.

In order to maintain backwards compatibility, the Internal variable was introduced. Set it to 0 (to use the old format) or 1 (to use the new format).

You can set the internal representation of Date::Manip's date string by using the Date_Init() function. Setting Date_Init('INTERNAL=1'); before you call DateParse() will force the return value of DateParse() to look like, "YYYYMMDDHHMMSS" (note, no colons).

That's just one possibility. Not sure if I'm on target, because I haven't tested the theory, but give it a try and see if it solves your problem.


Dave


In reply to Re: Date::Manip Help by davido
in thread Date::Manip Help by Agyeya

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.