Xero - beautiful accounting software

Xero Developer Help Center

Xero Developer Community

Community > API Endpoints >

Xero API date range filter syntax for P/L Rerports?

Started by Erin Yu -   in API Endpoints

I know it's fromDate and toDate as outlined in the document http://blog.xero.com/developer/api/reports/#ProfitAndLoss but I'm not sure what to put in there. I've tried

fromDate>=DateTime.Parse(\"2011-09-01\") AND toDate<=DateTime.Parse(\"2011-09-30\")
fromDate>=DateTime.Parse(\"1 Sep 2011\") AND toDate<=DateTime.Parse(\"30 Sep 2011\")
fromDate=\"1 Sep 2011\" AND toDate=\"30 Sep 2011\"
fromDate==\"1 Sep 2011\" AND toDate==\"30 Sep 2011\"
fromDate.ToString()==\"1 Sep 2011\" AND toDate.ToString()==\"30 Sep 2011\"

but none of them work. Does any one know the correct syntax to use? Thanks a lot.
Hi Anthony,

Try this format:

I've just had a look at the reports endpoint documentation on developer.xero.com and there aren't any actual examples of how to specify parameters. We'll try and get this fixed up in due course.


Daniel Barratt (Xero Staff)  

Is there any solution of it? Whenever I tries to get Profit&Loss report using from and toDate filter( e.g; https://api.xero.com/api.xro/2.0/Reports/ProfitAndLoss?fromDate=2013-06-01&toDate=2013-06-30 ) then it shows this error: "oauth_problem=consumer_key_unknown&oauth_problem_advice=Consumer%20key%20was%20not%20recognised".

However I find report if I just remove those date range parameters (e.g; https://api.xero.com/api.xro/2.0/Reports/ProfitAndLoss).

Any help? I've also tried with encoding the parameters. But it didn't work.

By the way I'm using PHP.

Maftahur Rahman  

Where you able to resolve this?

I am having the same issue with the Profit and Loss report trying to add fromDate and toDate

Fortunately, other parameters like trackingCategoryID are working.

Danyal Khan