Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Dear monks,

I am using Class::DBI module for database (MySQL) abstraction and I need to define some custom queries. Currently I am doing it like this:

Custom::Object->add_constructor(new_categories => 'category = ? ORDER BY when DESC LIMIT 3');

So far, so good, but one of the columns that I need to retrieve is a timestamp (column when), and I want to format it with custom DATE_FORMAT(...) SQL construct. Is there a simple way to do this? I have searched the documentation and it seems to suggest that I need to use Ima::DBI methods, but I somehow have a gut feeling that there might be a better solution.

Thank you for your help

Replies are listed 'Best First'.
Re: Class::DBI and custom columns
by liz (Monsignor) on Mar 02, 2004 at 08:45 UTC
Re: Class::DBI and custom columns
by perrin (Chancellor) on Mar 02, 2004 at 15:24 UTC
    Typically when you pull data into Class::DBI objects you would turn timestamp fields into date objects with a has_a like the one shown in the documentation. Then you use perl to format it however you want.