[SERVER-9626] Aggregation Framework needs to support more date conversion functions like date portion, or time portion of date type Created: 08/May/13  Updated: 03/Jan/18  Resolved: 11/Mar/16

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Gordon Roylance Assignee: Benjamin Murphy
Resolution: Duplicate Votes: 9
Labels: expression, usability
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-16347 Support for date aggregation operator... Closed
Related
is related to SERVER-11118 Add dateToString aggregation operator Closed
is related to SERVER-10651 Aggregation expressions to add/subtra... Closed
Participants:
Case:

 Description   

It would be very useful to have additional date conversion operators that would take a Date and return a date that only includes the date portion (time portion would be 0). Likewise for a getting the time of the day without the date.

Currently it is not possible (or at least not easily done) to group on the date of a Date field and have the date returned to the pipeline.

This wouldn't be too difficult to workaround if we could $divide a date, and then group on it, but it's not supported.

Other possible conversions may be nice like converting a Date to a Long, etc..



 Comments   
Comment by Charlie Swanson [ 11/Mar/16 ]

I'm closing this ticket as a duplicate of SERVER-16347 since I think they are very similar, and SERVER-16347 is more specific about the requested functionality.

If anyone has additional requests besides the functionality described in SERVER-16347 (including joerek's request in the first comment), I would ask that you please file an additional ticket and include specifics about what you are requesting, and some examples. Thank you!

Comment by Petri Liimatta [ 10/Jun/15 ]

Enabling Date construction in aggregation would be a good start. Currently it is not possible to execute

new ISODate("$myDateString")

in aggregation.

This would enable date aggregation operators like $year, $month and $dayOfMonth later in next pipeline steps.

Comment by Asya Kamsky [ 29/Jan/14 ]

It's certainly possible to do this in 2.4 using date math, but I agree that it's unwieldy and slightly ugly so this would be useful syntax to have/use.

Comment by Joerek van Gaalen [ 13/May/13 ]

In addition to this request. It would be useful to add to the date fuctions in the AF a unix timestamp function (milliseconds since 1970). With such an option you can group on any given time interval (for example 86400 seconds, or even per 4 hours: 14400 seconds) etc.. without having to stick with the $year, $dayOfYear functions

Generated at Thu Feb 08 03:20:59 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.