In my DB so much old data is there. I want to remove which is older than 3 months(90 days). For that I came upto here.

#!/usr/bin/perl use strict; use warnings; use MongoDB; $db_host="xxx.xx.xx.xxx"; #Removed ip for security purposes my $client = MongoDB::MongoClient->new(host => $db_host, port => 2 +7017); my $database = $client->get_database( 'ravi' ); my $collection1 = $database->get_collection( 'collection' ); my $removed1 = $collection1->remove({'Date'=>{'$lt'=>"14-03-2015"}}); print "\n$removed1";

here my problem is in my command if I write 14-03-2015 Its deleting second month & third month of year 2015 & 2104. But not 12 to 4 months of 2014 data. Suppose if i give 14-12-2014 like this it will remove total data of that collection. Means its considering only month but not year. Please show me a proper approach


In reply to Remove DB old data in Mongo using Perl by ravi45722

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.