<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:00:59 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>[DOCS-10610] Docs for SERVER-6310: Timezone support in date operators at query time</title>
                <link>https://jira.mongodb.org/browse/DOCS-10610</link>
                <project id="10380" key="DOCS">Documentation</project>
                    <description>&lt;h1&gt;&lt;a name=&quot;DocumentationRequestSummary%3A&quot;&gt;&lt;/a&gt;Documentation Request Summary: &lt;/h1&gt;

&lt;p&gt;Design document can be found through &lt;a href=&quot;https://docs.google.com/document/d/1I_x4NNWgfcXzmEFTPTYZkjIQVq_JUnZcxb5ak0o52oU/edit#heading=h.1rcba4503t2j&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://docs.google.com/document/d/1I_x4NNWgfcXzmEFTPTYZkjIQVq_JUnZcxb5ak0o52oU/edit#heading=h.1rcba4503t2j&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;&lt;a name=&quot;EngineeringTicketDescription%3A&quot;&gt;&lt;/a&gt;Engineering Ticket Description:&lt;/h1&gt;

&lt;div class=&quot;panel&quot; style=&quot;background-color: #EEEEEE;border-color: #ccc;border-width: 1px;&quot;&gt;&lt;div class=&quot;panelHeader&quot; style=&quot;border-bottom-width: 1px;border-bottom-color: #ccc;background-color: #6CB33F;&quot;&gt;&lt;b&gt;Issue Status as of July 26, 2017&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;panelContent&quot; style=&quot;background-color: #EEEEEE;&quot;&gt;
&lt;p&gt;&lt;b&gt;ISSUE SUMMARY&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;In previous versions of MongoDB, the date extraction operations &lt;tt&gt;$year&lt;/tt&gt;, &lt;tt&gt;$month&lt;/tt&gt;, etc. could only extract the information from Date types in the UTC time zone. This meant that&lt;br/&gt;
it was not possible to do grouping by date/time information in a local time zone. MongoDB does not have any concept about a server-wide local time zone.&lt;/p&gt;

&lt;p&gt;In versions 3.5.11 and newer, MongoDB still does not have a concept of a server-wide time zone, but the date extraction operators (&lt;tt&gt;$year&lt;/tt&gt;, &lt;tt&gt;$month&lt;/tt&gt;, &lt;tt&gt;$day&lt;/tt&gt;, &lt;tt&gt;$hour&lt;/tt&gt;, &lt;tt&gt;$minute&lt;/tt&gt;, &lt;tt&gt;$second&lt;/tt&gt;, &lt;tt&gt;$millisecond&lt;/tt&gt;, &lt;tt&gt;$isoYear&lt;/tt&gt;, &lt;tt&gt;$isoWeekYear&lt;/tt&gt; and {{$isoDayOfWeek} allow for a secondary format to specify a time zone to express a local time.&lt;/p&gt;

&lt;p&gt;&lt;b&gt;USER IMPACT&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;This is not a BC breaking change. The original syntax of the operators is still functional:&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;&amp;gt; db.c.aggregate({hour: {$hour: &apos;$lastUpdatedDate&apos;}})&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;A new syntax is now also supported, to allow for the extra &lt;tt&gt;timezone&lt;/tt&gt; field:&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;&amp;gt; db.c.aggregate({hour: {$hour: {date: &apos;$lastUpdatedDate&apos;}}})&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;&amp;gt; db.c.aggregate({hour: {$hour: {date: &apos;$lastUpdatedDate&apos;, timezone: &apos;Europe/Amsterdam&apos;}}})&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;&lt;b&gt;TECHNICAL DETAILS&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;The implementation of time zone support is done through &lt;a href=&quot;https://github.com/derickr/timelib&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;&quot;timelib&quot;&lt;/a&gt;. Several formats for the &lt;tt&gt;timezone&lt;/tt&gt; field are allowed:&lt;/p&gt;

&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;An &lt;a href=&quot;https://en.wikipedia.org/wiki/Tz_database&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;&quot;Olson Time Zone Idenfitier&quot;&lt;/a&gt;: &lt;tt&gt;America/New_York&lt;/tt&gt;, &lt;tt&gt;Europe/London&lt;/tt&gt;, etc.&lt;/li&gt;
	&lt;li&gt;A string describing an ISO 8601 time zone specification: &lt;tt&gt;-05:00&lt;/tt&gt;, &lt;tt&gt;+0445&lt;/tt&gt;, &lt;tt&gt;-03&lt;/tt&gt;, etc.&lt;/li&gt;
	&lt;li&gt;The strings &lt;tt&gt;Z&lt;/tt&gt;, &lt;tt&gt;UTC&lt;/tt&gt; and &lt;tt&gt;GMT&lt;/tt&gt;&lt;/li&gt;
	&lt;li&gt;Or an expression that evaluates from one of the above. This allows you to fetch the time zone information from a separate field in your document.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;&lt;b&gt;ADDITIONAL CHANGES&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;The &lt;tt&gt;$dateToString&lt;/tt&gt; operator has also been updated (&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-28610&quot; title=&quot;Add time zone support, and %z and %Z arguments to the $dateToString operator&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-28610&quot;&gt;&lt;del&gt;SERVER-28610&lt;/del&gt;&lt;/a&gt;), and the new operators &lt;tt&gt;$dateFromParts&lt;/tt&gt; and &lt;tt&gt;$dateToParts&lt;/tt&gt; (&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-28613&quot; title=&quot;Add the $dateToParts and $dateFromParts A/F operators&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-28613&quot;&gt;&lt;del&gt;SERVER-28613&lt;/del&gt;&lt;/a&gt;), and &lt;tt&gt;$dateFromString&lt;/tt&gt; (&lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-29208&quot; title=&quot;Add the $dateFromString A/F operator (without tz support)&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-29208&quot;&gt;&lt;del&gt;SERVER-29208&lt;/del&gt;&lt;/a&gt;, &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-29209&quot; title=&quot;Add TZ support to the new $dateFromString A/F operator&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-29209&quot;&gt;&lt;del&gt;SERVER-29209&lt;/del&gt;&lt;/a&gt;) have been added, each also supporting time zones.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;h5&gt;&lt;a name=&quot;Originaldescription&quot;&gt;&lt;/a&gt;Original description&lt;/h5&gt;

&lt;p&gt;The date operators ($dayOfMonth, $dayOfWeek, $dayOfYear, $hour, $minute, $month, $week and $year) currently work for UTC. This causes the $group pipeline operator to insert certain rows in wrong bucket due to certain timezones being in another day.&lt;/p&gt;

&lt;p&gt;As an example, say you&apos;re showing website statistics for a US based company and at December 31st 2011 at 10:00 PM EST someone finally visits the website, if the aggregation framework didn&apos;t respect timezones (like it does now) it&apos;d group the data point the next day (since it&apos;s stored as 2012-01-01T02:00:00Z). Which, if you&apos;re grouping data by year is quite the error as it would look like you&apos;d have visitors from the future.&lt;/p&gt;

&lt;p&gt;Being able to set the timezone, either per query or per connection would solve this. &lt;/p&gt;</description>
                <environment></environment>
        <key id="410574">DOCS-10610</key>
            <summary>Docs for SERVER-6310: Timezone support in date operators at query time</summary>
                <type id="3" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14718&amp;avatarType=issuetype">Task</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="13201">Fixed</resolution>
                                        <assignee username="ravind.kumar">Ravind Kumar</assignee>
                                    <reporter username="emily.hall">Emily Hall</reporter>
                        <labels>
                            <label>aggregation</label>
                            <label>expression</label>
                            <label>timezone</label>
                            <label>usability</label>
                    </labels>
                <created>Mon, 31 Jul 2017 17:33:40 +0000</created>
                <updated>Sun, 29 Oct 2023 13:59:20 +0000</updated>
                            <resolved>Thu, 21 Sep 2017 04:46:02 +0000</resolved>
                                                    <fixVersion>3.5.11</fixVersion>
                                        <due></due>
                            <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="1678375" author="kay.kim@10gen.com" created="Thu, 21 Sep 2017 04:46:02 +0000"  >&lt;p&gt;&lt;a href=&quot;https://github.com/mongodb/docs/pull/2961&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/docs/pull/2961&lt;/a&gt;&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10320">
                    <name>Documented</name>
                                            <outwardlinks description="documents">
                                        <issuelink>
            <issuekey id="43448">SERVER-6310</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                            <outwardlinks description="duplicates">
                                        <issuelink>
            <issuekey id="403639">DOCS-10525</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="406921">DOCS-10566</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Thu, 21 Sep 2017 04:46:02 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        6 years, 21 weeks ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[]]></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_10857" key="com.pyxis.greenhopper.jira:gh-epic-link">
                        <customfieldname>Epic Link</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>DOCS-10575</customfieldvalue>
                        </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>luke.bonanomi@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            6 years, 21 weeks ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                            <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>emily.hall</customfieldvalue>
            <customfieldvalue>kay.kim@mongodb.com</customfieldvalue>
            <customfieldvalue>ravind.kumar</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|htc00n:</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10053" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>Time In Status</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|htbm3b:</customfieldvalue>

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