You're passing Perl code as literal SQL to the database. This can't work. Try something like this:
my $dt = DateTime->now()->subtract(days => 180);
my $parser = $schema->storage->datetime_parser;
my $entry_rs = $schema->resultset('table_name')->search_rs(
{
table_id => $row->table_id,
utc_timestamp => { '<', $parser->format_datetime($dt) },
},
)->all;
This code uses datetime_parser
in DBIx::Class::Storage::DBI
to retrieve the DateTime::Format
class appropriate for your database. Then it calls format_datetime
on that class to convert the DateTime
object to a string that can be passed to the DB.