I want to extract year, quarter and month from date using spring-data-mongodb and referred to this link Mongodb query specific month|year not date , 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.
     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<ResultTemplate> groupResults = mongoTemplate.aggregate(agg2,ResultTemplate.class,
             ResultTemplate.class);
              System.out.println(groupResults.getMappedResults());
 
    