how to extract year from date with timestamp from jcr:property of a page using querybuilder api aem | Community
Skip to main content
krupesh_4129
Level 2
July 13, 2017
Solved

how to extract year from date with timestamp from jcr:property of a page using querybuilder api aem

  • July 13, 2017
  • 2 replies
  • 1404 views

I have two filters on page viz. Year & Category. Based on this filters i need to retrieve the pages from the repository and show it on the page. I am using querbuilder api to fetch the pages based on searching "year & category" properties in the page property of the list of pages.However, I have a date property in page properties of list of pages from where i need to compare the year filter of my query. But filter=year is in the format "2017" & date=timestamp in pageproperties of page is in format of "2017-09-18T01:15:00.000+05:30". So how do i compare the year filter & date in page properties to fetch these particular pages through my query.

query map: 
  if (StringUtils.isNotBlank(year)) {
  map.put("3_property", "year");
  map.put("3_property.value", 2017);
  }

page property:

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by krupesh_4129

Got the solution.

map.put("daterange.property", "date"); //Since the property name is date as per your image.
map.put("daterange.lowerBound", year + "-01-01"); //First day of the year
map.put("daterange.upperBound", year + "-12-31"); //Last day of the year

2 replies

krupesh_4129
krupesh_4129AuthorAccepted solution
Level 2
July 13, 2017

Got the solution.

map.put("daterange.property", "date"); //Since the property name is date as per your image.
map.put("daterange.lowerBound", year + "-01-01"); //First day of the year
map.put("daterange.upperBound", year + "-12-31"); //Last day of the year