Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Sleep time series start date one day off

ANSWERED

Below is an example of some output from the Sleep startTime time series. The dateTime value is always off by one day for this user. What am I not seeing? How can I figure out the correct starting day (the time is correct).

Thanks!

 

(
        {
        dateTime = "2016-07-24";
        value = 441;
    },
        {
        dateTime = "2016-07-25";
        value = 452;
    },
        {
        dateTime = "2016-07-26";
        value = 461;
    },
        {
        dateTime = "2016-07-27";
        value = 439;
    },
        {
        dateTime = "2016-07-28";
        value = 483;
    },
        {
        dateTime = "2016-07-29";
        value = 451;
    },
        {
        dateTime = "2016-07-30";
        value = 435;
    },
        {
        dateTime = "2016-07-31";
        value = 312;
    },
        {
        dateTime = "2016-08-01";
        value = 486;
    }
)

 

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

@ThatOneCat Are you expecting to see the date of the night they went to sleep? Because sleep is logged on the date the user woke up, not the night they went to sleep.

Andrew | Community Moderator, Fitbit

What motivates you?

View best answer in original post

Best Answer
0 Votes
5 REPLIES 5

@ThatOneCat Are you expecting to see the date of the night they went to sleep? Because sleep is logged on the date the user woke up, not the night they went to sleep.

Andrew | Community Moderator, Fitbit

What motivates you?

Best Answer
0 Votes
Ah, it all makes sense now! So what happens if they went to sleep after midnight?
Best Answer
0 Votes

@ThatOneCat If it's after midnight (and assuming they don't sleep until 12am the next day Smiley LOL) then it will still be logged on that day.

 

Here's what it looks like using my account and this endpoint:

https://api.fitbit.com/1/user/-/sleep/startTime/date/today/2016-05-11.json

 

I have sleep logged on May 11th, but went to sleep 11:34pm May 10th

"dateTime": "2016-05-11",
      "value": "23:34"

"value" shows that I went to sleep at 23:34 (11:34pm) but the sleep is still logged on the 11th.

 

 

As for sleep that started after midnight, here's an example of that:

"dateTime": "2016-07-23",
      "value": "00:30"

Sleep started and ended on the same day, so it's still logged that day.

 

 

I think you might be using "minutesAsleep" instead of "startTime" though. Robot wink

Andrew | Community Moderator, Fitbit

What motivates you?

Best Answer
0 Votes

Ok, it might be super obvious but then how do you tell which day the sleep started on?

Best Answer
0 Votes

@ThatOneCat If you're using that endpoint then I assume if "value" returns anything equal to or less than "23:59", then the start date of sleep is the day before "dateTime".

 

It's a little difficult to make assumptions like that, but that's the only way I can tell using that endpoint (what if they took a nap or something late at night? Robot Frustrated).

 

If you look at a specific day though, it will return the startTime with the date (which makes it easier):

"startTime": "2016-05-10T23:34:30.000"

https://api.fitbit.com/1/user/-/sleep/date/2016-05-11.json

 

Doesn't really help if you're trying to grab multiple days at once. Robot Sad

Andrew | Community Moderator, Fitbit

What motivates you?

Best Answer
0 Votes