0

I am using the Stack Exchange API to get the number of all unanswered questions in a particular tag. I am trying to create a table which shows the change in value over a period of time. Therefore, I am using fromdate and todate. The issue is that my result is varying slightly.

Setting todate to 2020-07-01 returns a total of 23517 questions, but as of now, the site shows 23526 in the unanswered tab.

double-beep
  • 5,031
  • 17
  • 33
  • 41
SJDT
  • 23
  • 4
  • Why is that even important to you? A +/-0.03% deviation seems pretty irrelevant to me for purposes of statistical evaluation. My first suspicion would be a timezone difference, btw. –  Jul 01 '20 at 22:48
  • This works as intended. 2020-07-01 means 2020-07-01 00:00:00 UTC. If you want to get all the unanswered questions, remove from date and todate. If you only remove todate, then you will get questions from 2009-01-01 00:00:00 UTC to the time you make the API call. – double-beep Jul 02 '20 at 04:13
  • @double-beep the reason to use todate is because I want historical data. And only way i could think about doing it is by may be keeping the fromdate fixed and change the todate. – SJDT Jul 02 '20 at 18:02
  • @taschi i thought so too. However, this deviation is across various tags. Curious to know – SJDT Jul 02 '20 at 18:34
  • todate takes either a day in the format YYYY-MM-DD or a number which is the number of secs (not millisecs!) elapsed from Jan 1st, 1970. You can generate that kind of date and work with that. – double-beep Jul 03 '20 at 04:13

1 Answers1

0

Both todate and fromdate accept two types of arguments:

  • Dates in the format YYYY-MM-DD, (which are actually YYYY-MM-DD 00:00:00 UTC). You can also pass HH:MM:SS, which is optional.
  • Dates in Unix epoch time (number of seconds since Jan 1st, 1970 00:00:00 UTC).

Without a todate parameter, API returns the unanswered questions from fromdate to the time the API call was made.

You, however, pass a fromdate in YYYY-MM-DD, which appears to be some hours earlier and hence the difference in the numbers.

Reference: https://api.stackexchange.com/docs/dates

double-beep
  • 5,031
  • 17
  • 33
  • 41