in reply to Date subtraction (intervals) w/Class::DBI

I recommend using MySQL's built in date handling functions e.g. you could rewrite the constructor like this:
Company->add_constructor( get_recent => 'DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= created_on ' );
Also, what type have you used for the created_on field? If you set its type to TIMESTAMP, then MySQL will automatically update it.

Update - This automatic update will only happen if created_on is the 1st TIMESTAMP field in the table.

Replies are listed 'Best First'.
Re^2: Date subtraction (intervals) w/Class::DBI
by saberworks (Curate) on Oct 16, 2004 at 00:25 UTC
    That's a great suggestion, thanks a lot! I used DATETIME for created_on, and a timestamp will update it any time the record gets updated, not only when the record is created. Also, I need this for other queries, so I really appreciate your suggestion.
Re^2: Date subtraction (intervals) w/Class::DBI
by waswas-fng (Curate) on Oct 15, 2004 at 18:02 UTC
    Not so true anymore depending on the version you are running:

    Beginning with MySQL 4.1.2, you have more flexible control over when a +utomatic TIMESTAMP initialization and updating occur and which column + should have those behaviors: You can assign the current timestamp as the default value and the auto +-update value, as before. But now it is possible to have just one aut +omatic behavior or the other, or neither of them. You can specify which TIMESTAMP column to automatically initialize or +update to the current date and time. This no longer need be the first + TIMESTAMP column. The following discussion describes the revised syntax and behavior. No +te that this information applies only to TIMESTAMP columns for tables + not created with MAXDB mode enabled. As noted earlier in this sectio +n, MAXDB mode causes columns to be created as DATETIME columns. </i>
    ... more info at: MySQL doc page.


    -Waswas