Questions: 1. How do you take a date in the form 'Month YYYY' and
convert it to the form 'YYYY-MM-DD'?
(I am assuming that DD will be 00 since I do not have any days to convert)
Example: March 1990 => 1990-03-00

2. How do you reverse the process, and convert
from'YYYY-MM-DD' to 'Month YYYY'?
Example: 1990-03-00 => March 1990

Background: I am using the CueCat sample code from Brent Michalski
(moderator of the Perl channel for Dr. Dobb's Online) to catalog my book collection.
The code is located at: Roll Your Own Data Capture

This code in and of itself works just fine, but I want to modify the code to reformat the date
into the format expected by MySql, so I can store the data in the table with a DATE datatype,
instead of VARCHAR, as I am using now. (I want to be able to sort each author's work in
chronological order, so Book 1 of a trilogy will show up before Book 2, etc)

I am assuming that since the code already parses out the date and puts it into a variable,
I just need to write a subroutine that will reformat this value. I just don't know what
Regular Expression or function to use to do the conversion. I've looked at Date::Ordinal,
which looks like what I need, but I don't understand how to use it.

In reply to How do you format dates for entry into MySql? by glamring

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.