I am working with MongoDB
and am not having an easy time trying to add the less-than to my working $gte
query. The below query works when I remove the $lt
line from it.
I am trying to get records between two dynamic dates - minutes. That does work for $gte
, but introducing the $lt
gives me nothing.
I validated the variables for the dates are correct. Am I overcomplicating this?
Perl code:
my $cursor = $collection->find({
create_date => {
'$gte' => DateTime->new(
year => $dtpast_year,
month => $dtpast_month,
day => $dtpast_day,
hour => $dtpast_hour,
minute => $dtpast_minute
),
'$lt' => DateTime->new(
year => $dtpresent_year,
month => $dtpresent_month,
day => $dtpresent_day,
hour => $dtpresent_hour,
minute => $dtpresent_minute
)
}
});
I cleaned it up a bit with the same issue. I will
my $present = DateTime->new(
year => $dtpresent_year,
month => $dtpresent_month,
day => $dtpresent_day,
hour => $dtpresent_hour,
minute => $dtpresent_minute
);
my $past = DateTime->new(
year => $dtpast_year,
month => $dtpast_month,
day => $dtpast_day,
hour => $dtpast_hour,
minute => $dtpast_minute
);
my $cursor = $collection->find({create_date => {'$gte' => $past}});