MongoDB ISO date query between two dates in Perl

I am working with MongoDB

and I am having a hard time trying to add less than to my working query.The $gte

following query works when I remove a line from it $lt

.

I am trying to get records between two dynamic dates - minutes. This works for $gte

, but the introduction $lt

gives me nothing.

I have verified that the variables for dates are correct. Am I cheating on something?

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 up this issue a bit. 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}});

      

+3


source to share





All Articles