title: Extract year and month and day from date using spring-data-mongodb
body: <p>I want to extract year, quarter and month from date using spring-data-mongodb and referred to this link <a href="https://stackoverflow.com/questions/18907566/mongodb-query-specific-monthyear-not-date">Mongodb query specific month|year not date</a> , can someone help me in writing the same query in spring-data-mongodb.
  Below is the code snippet for extracting year from myDate, with spring-data-mongodb, but it does NOT work.</p>
  
  <pre><code>     Criteria c= null;
       Aggregation agg2 = null;
  
       c = Criteria.where("year(myDate)").gte(2000).
               andOperator(Criteria.where("year(myDate)").lte(2017);
             agg2 = newAggregation(
                  match( c),
                project("retailerName","unitsSold","year" )
  
                           .andExpression("year(myDate)").as("year"),
                   group(fields().and("retailerName").and("year"))
                   .sum("unitsSold").as("netSales")
                      ,
  
  
  
                    sort(Sort.Direction.ASC, "year")
                   );
                 System.out.println("testing : : : " + agg2);
                AggregationResults&lt;ResultTemplate&gt; groupResults = mongoTemplate.aggregate(agg2,ResultTemplate.class,
               ResultTemplate.class);
                System.out.println(groupResults.getMappedResults());
  </code></pre>