I have to replicate Report layout using Visualforce and add Time Frame picklists (Fiscal Year, Fiscal Quarter, Calendar Year, Calendar Quarter etc.) based on today's date.

Is it possible to query default Time Frame values which appear in Report layout? Or even write a query to return From and To Date values by passing Time Frame literal? If yes, then how?

UPDATE: I attach the screenshot to make this problem more clear: Taken from standard Report layout

  1. How to get a list of all standard ranges like "Previous FY"?
  2. How to get relative Date values based on a selected range and today's date?

The first thing that comes out is to hardcode the range values and develop Apex method for each range to calculate the relative date values "From" and "To". I am trying to find easier way to do this.

  • are you asking if there is a soql query or metadata query to retrieve all supported date literals? – cropredy Apr 22 '16 at 17:35
  • Please check the updated question, I edited it to be more specific. Thanks. – justasd Apr 25 '16 at 7:59
  • 1
    so -- you want the user to select from a picklist of relative date literals and then you want to echo back to the user what the actual start/end dates are for the chosen relative date literal? There's no query that I know of that gives you the picklist - but that is a one-time copy/paste from the doc. The second part: echoing back -- perhaps someone in the community has written that code – cropredy Apr 25 '16 at 13:16
  • @cropredy, I also haven't found a query for that. I ended up by hardcoding date literal values and then wrote a method for each literal to get relative date ranges. I used SOQL to retrieve fiscal quarters from Period object. All other dates are calculated using Apex. – justasd Apr 29 '16 at 6:48

In short, yes.

You can pass actual dates to a SoQL statement

WHERE CreatedDate > 2005-10-08T01:02:03Z

Or you can pass some relative values

WHERE CreatedDate > TODAY

There are many more keywords, which you can find here

  • Hi Sebastian, thanks, please check the updated question, I edited it to be more specific. – justasd Apr 25 '16 at 7:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.