<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 02:54:12 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[SERVER-465] date matcher helpers</title>
                <link>https://jira.mongodb.org/browse/SERVER-465</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;things like $month, $year, $curMonth, &lt;br/&gt;
some way to do previous month, etc...&lt;/p&gt;

&lt;p&gt;maybe&lt;/p&gt;
&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;{ date : { $year : 2009 , $month : 10 } )&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;

&lt;p&gt;not sure yet&lt;/p&gt;</description>
                <environment></environment>
        <key id="10970">SERVER-465</key>
            <summary>date matcher helpers</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="9">Done</resolution>
                                        <assignee username="backlog-server-query">Backlog - Query Team</assignee>
                                    <reporter username="eliot">Eliot Horowitz</reporter>
                        <labels>
                            <label>query_triage</label>
                    </labels>
                <created>Wed, 9 Dec 2009 07:25:44 +0000</created>
                <updated>Tue, 6 Dec 2022 05:51:08 +0000</updated>
                            <resolved>Fri, 16 Mar 2018 14:35:27 +0000</resolved>
                                                                    <component>Querying</component>
                                        <votes>23</votes>
                                    <watches>18</watches>
                                                                                                                <comments>
                            <comment id="1836495" author="ian@10gen.com" created="Fri, 16 Mar 2018 14:35:27 +0000"  >&lt;p&gt;As per the above comments, this is now possible with the introduction of &lt;tt&gt;$expr&lt;/tt&gt; in 3.6.0!&lt;/p&gt;</comment>
                            <comment id="1829205" author="asya" created="Fri, 9 Mar 2018 19:12:47 +0000"  >&lt;p&gt;To find all dates that are in a particular month (birthday view) and sort them:&lt;/p&gt;
&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;db.birthdays.aggregate([&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;  /* match birthdays in June (6) */&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;   {$match:{$expr:{$eq:[6,{$month:&quot;$db&quot;}]}}},&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;  /* construct the date this year for the June birthday */&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;   {$addFields:{birthdayThisMonth:{$dateFromParts:{year:2018, month:{$month:&quot;$db&quot;},day:{$dayOfMonth:&quot;$db&quot;}}}}},&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;  /* sort by birthday this year */&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;   {$sort:{birthdayThisMonth:1}}&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;])&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;{ &quot;_id&quot; : ObjectId(&quot;5aa2db5594fb72e37873fb6b&quot;), &quot;db&quot; : ISODate(&quot;1936-06-04T04:00:00Z&quot;), &quot;birthdayThisMonth&quot; : ISODate(&quot;2018-06-04T00:00:00Z&quot;) }&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;{ &quot;_id&quot; : ObjectId(&quot;5aa2db4f94fb72e37873fb6a&quot;), &quot;db&quot; : ISODate(&quot;1965-06-12T04:00:00Z&quot;), &quot;birthdayThisMonth&quot; : ISODate(&quot;2018-06-12T00:00:00Z&quot;) }&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;{ &quot;_id&quot; : ObjectId(&quot;5aa2db5e94fb72e37873fb6c&quot;), &quot;db&quot; : ISODate(&quot;1962-06-21T04:00:00Z&quot;), &quot;birthdayThisMonth&quot; : ISODate(&quot;2018-06-21T00:00:00Z&quot;) }&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;</comment>
                            <comment id="1829192" author="asya" created="Fri, 9 Mar 2018 19:05:10 +0000"  >&lt;p&gt;With &lt;a href=&quot;https://docs.mongodb.com/manual/reference/operator/query/expr/index.html&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;$expr&lt;/a&gt; added in 3.6 using date expressions available in &lt;a href=&quot;https://docs.mongodb.com/manual/reference/operator/aggregation/&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;aggregation&lt;/a&gt; these type of comparisons can now be done:&lt;/p&gt;

&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;db.coll.find(find({$expr:{$eq:[1,{$month:&quot;$d&quot;}]}})&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;{ &quot;_id&quot; : ObjectId(&quot;5a5f8b24c22e16a81e507ad8&quot;), &quot;d&quot; : ISODate(&quot;1970-01-01T00:00:00Z&quot;) }&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;{ &quot;_id&quot; : ObjectId(&quot;5a5f8b27c22e16a81e507ad9&quot;), &quot;d&quot; : ISODate(&quot;2018-01-17T17:43:03.022Z&quot;) }&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;db.coll.find({$expr:{$gte:[{$hour:&quot;$d&quot;},17]}})&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;{ &quot;_id&quot; : ObjectId(&quot;5a5f8b27c22e16a81e507ad9&quot;), &quot;d&quot; : ISODate(&quot;2018-01-17T17:43:03.022Z&quot;) }&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;db.coll.find({$expr:{$gte:[{$hour:{date:&quot;$d&quot;,timezone:&quot;-0400&quot;}},17]}})&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;{ &quot;_id&quot; : ObjectId(&quot;5a5f8b24c22e16a81e507ad8&quot;), &quot;d&quot; : ISODate(&quot;1970-01-01T00:00:00Z&quot;) }&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;

&lt;p&gt;Starting with 3.7.3 (dev version) it&apos;s also possible to construct dates that represent &quot;last day of previous month&quot; for comparisons.&lt;/p&gt;
</comment>
                            <comment id="24477" author="keithbranton" created="Tue, 22 Feb 2011 22:51:24 +0000"  >&lt;p&gt;@Chris, I didn&apos;t really consider index optimization because in my examples of social calendar people usually only have a few hundred friends at most, and, assuming lookup for the friends is indexed, further index optimization on the date is not really likely to help much.  &lt;/p&gt;

&lt;p&gt;I&apos;d have thought that if the date field was indexed then queries that could not be done with an index range scan would result in a full index scan. Either way scanning an index is way faster than scanning the collection.&lt;/p&gt;

&lt;p&gt;In my system I store birthdays as text strings YYYYMMDD and use regexes and ranges for the various queries I need. It works fine and performs well enough, except for the year-less birthday list. That&apos;s something I&apos;d like to do.&lt;/p&gt;

&lt;p&gt;I&apos;d just prefer that a date was actually stored as a date, and that we had a much more natural way to query them, and ideally sort on them (if sorting is in the scope of this change).&lt;/p&gt;
</comment>
                            <comment id="24464" author="cwestin" created="Tue, 22 Feb 2011 21:56:48 +0000"  >&lt;p&gt;Dates are currently stored as millisecond counts&lt;br/&gt;
(see &lt;a href=&quot;http://bsonspec.org/#/specification&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://bsonspec.org/#/specification&lt;/a&gt;), so indexing them for searching&lt;br/&gt;
purposes isn&apos;t great unless you&apos;re going to search for ranges specified that&lt;br/&gt;
way.&lt;/p&gt;

&lt;p&gt;For the use case that Keith describes, the best thing to do is to handle the&lt;br/&gt;
component parts yourself:&lt;/p&gt;

&lt;p&gt;// create an index like this&lt;br/&gt;
db.profile.ensureIndex(&lt;/p&gt;
{&quot;birthDate.month&quot;:1, &quot;birthDate.day&quot;:1}
&lt;p&gt;);&lt;/p&gt;

&lt;p&gt;// save a person&apos;s profile&lt;br/&gt;
db.profile.save({&lt;br/&gt;
  firstName:&quot;Fred&quot;, &lt;br/&gt;
  lastName:&quot;Flintstone&quot;,&lt;br/&gt;
  birthDate: &lt;/p&gt;
{
    year: 1963,
    month: 2,
    day: 17}
&lt;p&gt;});&lt;/p&gt;

&lt;p&gt;// so that you can do this:&lt;br/&gt;
db.profile.find(&lt;/p&gt;
{&quot;birthDate.month&quot;:2, &quot;birthDate.day&quot;:17}
&lt;p&gt;).explain();&lt;br/&gt;
&amp;gt; db.profile.find(&lt;/p&gt;
{&quot;birthDate.month&quot;:2, &quot;birthDate.day&quot;:17}
&lt;p&gt;).explain();&lt;br/&gt;
{&lt;br/&gt;
        &quot;cursor&quot; : &quot;BtreeCursor birthDate.month_1_birthDate.day_1&quot;,&lt;br/&gt;
        &quot;nscanned&quot; : 1,&lt;br/&gt;
        &quot;nscannedObjects&quot; : 1,&lt;br/&gt;
        &quot;n&quot; : 1,&lt;br/&gt;
        &quot;millis&quot; : 3,&lt;br/&gt;
        &quot;nYields&quot; : 0,&lt;br/&gt;
        &quot;nChunkSkips&quot; : 0,&lt;br/&gt;
        &quot;isMultiKey&quot; : false,&lt;br/&gt;
        &quot;indexOnly&quot; : false,&lt;br/&gt;
        &quot;indexBounds&quot; : &lt;/p&gt;
{
                &quot;birthdate.month&quot; : [
                        [
                                2,
                                2
                        ]
                ],
                &quot;birthdate.day&quot; : [
                        [
                                17,
                                17
                        ]
                ]
        }
&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;The alternative is to index a Date field; issuing a query like the above on&lt;br/&gt;
that will require computing the millisecond value of the beginning and end&lt;br/&gt;
of the date range and querying over that:&lt;/p&gt;

&lt;p&gt;db.profile2.ensureIndex(&lt;/p&gt;
{birthDate:1}
&lt;p&gt;);&lt;/p&gt;

&lt;p&gt;// save a person&apos;s profile&lt;br/&gt;
db.profile2.save(&lt;/p&gt;
{
  firstName:&quot;Fred&quot;, 
  lastName:&quot;Flintstone&quot;,
    birthDate: new Date(
      /* year */1963,
      /* zero-based-month */1,
      /* one-based-day */ 17,
      /* minutes */ 0,
      /* seconds */ 0,
      /* milliseconds */ 0)
  }
&lt;p&gt;);&lt;/p&gt;

&lt;p&gt;/*&lt;br/&gt;
  But to protect ourselves against future use of other sub-components, we&lt;br/&gt;
  should really do the birthday query as&lt;br/&gt;
*/&lt;br/&gt;
db.profile2.find({birthDate:&lt;br/&gt;
        {&apos;$gte&apos;: new Date(1963, 1, 17, 0, 0, 0), &lt;br/&gt;
         &apos;$lt&apos;: new Date(1963, 1, 18, 0, 0, 0)}});&lt;/p&gt;

&lt;p&gt;/*&lt;br/&gt;
  But this is painful to formulate, especially for dates on the last day of&lt;br/&gt;
  the month or year, where you have to adjust the other date fields for the&lt;br/&gt;
  upper bound.  It also doesn&apos;t handle Keith&apos;s requirement to ignore the year.&lt;br/&gt;
  Given the storage format, that&apos;s not practical with a native Date.&lt;br/&gt;
*/&lt;/p&gt;

&lt;p&gt;Eliot, what is the use case you have in mind?&lt;/p&gt;</comment>
                            <comment id="22305" author="keithbranton" created="Wed, 12 Jan 2011 21:23:48 +0000"  >&lt;p&gt;It would be really nice to have some date manipulation in the database. Working on social networks it is quite common to want:&lt;/p&gt;

&lt;p&gt;A list of all your friends in birthday order, irrespective of year of birth (could be sorted client side - but that would not support paging through a big cursor very well though. Some social networkers have thousands of &quot;friends&quot;).&lt;/p&gt;

&lt;p&gt;A list of birthdays coming up this week for emails like Facebook sends out (that&apos;s pretty easy to do client side by providing a range, but easier and &quot;dry&quot;-er if the db can do it). BirthdayAlarm.com displays a page like that, and uses oracle date functions to accomplish it.&lt;/p&gt;

&lt;p&gt;Being able to appropriately populate a month view calendar with friends birthdays - which requires finding all friends with birthdays in the given month irrespective if their year of birth.&lt;/p&gt;</comment>
                            <comment id="13482" author="sfeley" created="Tue, 6 Apr 2010 17:37:40 +0000"  >&lt;p&gt;This starts to feel a bit like feature bloat to me, and you&apos;ll begin to collide with different assumptions made about date calculation in different languages.  (Both human and computer.)  It&apos;s so simple to implement these with existing query operators that I&apos;d rather see it done at the driver or framework level.&lt;/p&gt;
</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                            <outwardlinks description="depends on">
                                        <issuelink>
            <issuekey id="370757">SERVER-28611</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="43448">SERVER-6310</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>7.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                <customfield id="customfield_12751" key="com.atlassian.jira.plugin.system.customfieldtypes:multiselect">
                        <customfieldname>Assigned Teams</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="25143"><![CDATA[Query]]></customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Tue, 6 Apr 2010 17:37:40 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        5 years, 47 weeks, 5 days ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[<s><a href='https://jira.mongodb.org/browse/SERVER-28611'>SERVER-28611</a></s>]]></customfieldvalue>


                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10057" key="com.atlassian.jira.toolkit:lastusercommented">
                        <customfieldname>Last comment by Customer</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>true</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10056" key="com.atlassian.jira.toolkit:lastupdaterorcommenter">
                        <customfieldname>Last commenter</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>alexander.golin@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            5 years, 47 weeks, 5 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_10000" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Old_Backport</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10000"><![CDATA[No]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>asya.kamsky@mongodb.com</customfieldvalue>
            <customfieldvalue>backlog-server-query</customfieldvalue>
            <customfieldvalue>cwestin</customfieldvalue>
            <customfieldvalue>eliot</customfieldvalue>
            <customfieldvalue>ian@mongodb.com</customfieldvalue>
            <customfieldvalue>keithbranton</customfieldvalue>
            <customfieldvalue>sfeley</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrptyv:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hr9cbb:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>4732</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_23361" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Requested By</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10053" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>Time In Status</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_22870" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Triagers</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hszxrz:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                    </customfields>
    </item>
</channel>
</rss>