[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Omaha.pm] SQL . sprintf



Depending on the database, and if you’re only working with “Today” you may not need to use any Class::Date spinoffs:

$filter .= “ AND extend(arrival_date,year to day) >= extend(Today, year to day) “;

 

 


From: omaha-pm-bounces@pm.org [mailto:omaha-pm-bounces@pm.org] On Behalf Of Kenneth Thompson
Sent: Tuesday, August 16, 2005 3:17 PM
To: omaha-pm@pm.org
Subject: Re: [Omaha.pm] SQL . sprintf

 

I’m beginning to really like perl...

 

Before

    my @T = Date::Calc::Today;

    $filter .= " AND extend(arrival_date,year to day) >= '" .

       sprintf("%04d-%02d-%02d",$T[0..2]) . "'";

 

After

    $filter .= " AND extend(arrival_date,year to day) >= " .

       sprintf("'%04d-%02d-%02d'", Date::Calc::Today);

 

After-After

    $filter .= " AND extend(arrival_date,year to day) >= ‘" .

       new Control::DateTime->format("%Y-%02d-%02d") . "'";

 

(Control::DateTime being a massaged Class::Date)