[rt-users] Searching and comparing two date field values instead of value with supplied valid

Thomas Sibley trs at bestpractical.com
Mon Aug 12 14:45:12 EDT 2013


On 08/12/2013 11:39 AM, Landon wrote:
> The help I need though is on comparing dates using RT::Date or
> something.  If I load the CF.{ServerCreated} and the Created value how
> do I compare them reliably in modules?  
> 
> Would this work?
> ...
> my $ServerCreated = DateTime::Format::MySQL->parse_datetime(
> $ticket->FirstCustomFieldValue('ServerCreated') );
> my $Created = DateTime::Format::MySQL->parse_datetime(
> $ticketObj->Created );
> $ticket->SetStatus( 'resolved' ) if $ServerCreated < $Created;
>
my $server_created = RT::Date->new( $ticket->CurrentUser );
$server_created->Set(
    Format => 'sql',
    Value  => $ticket->FirstCustomFieldValue('ServerCreated'),
);

if ($server_created->Unix < $ticket->CreatedObj->Unix) {
    ...
}




More information about the rt-users mailing list