I'm having trouble using my API key with the todate parameter. My query works fine with todate:

$ curl -s "https://api.stackexchange.com/2.2/search/advanced?todate=2015-07-21&site=stackoverflow&tagged=abap&filter=total" | gunzip

And it works fine with my API key if I remove todate:

$ curl -s "https://api.stackexchange.com/2.2/search/advanced?site=stackoverflow&tagged=abap&filter=total&key=$mykey" | gunzip

But for some reason I can't use both:

$ curl -s "https://api.stackexchange.com/2.2/search/advanced?todate=2015-07-21&site=stackoverflow&tagged=abap&filter=total&key=$mykey" | gunzip

1 Answer 1


This is .

From the Date Formats doc page:

For convenience when doing ad-hoc queries without a key an alternative date format is accepted: YYYY-MM-DD HH:MM:SS, where the hour, minute, and second values are optional.
Applications should not ship using this date format (as all applications should ship with a key), it is provided just to ease rapid development.

(Emphasis mine)

So you need to specify dates in unix epoch time. Which means for 2015-07-21 you would use:


EXCEPT: You probably want results to 2015-07-21 inclusive, in which case your todate should be 1437523200 -- which corresponds to midnight (UTC) of 2015-07-22 -- that is the very end of 2015-07-21.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .