Using executed_after to filter current day's Time Entries

Hi all

Using powershell to pull out the time entries made by agents since midnight of the current day.

The below returns time entries for previous days as well. Perhaps executed_after does not filter the way I am expecting it to?

I could just loop through and drop the time entries from previous days but feels a bit of a hack.

https://redacted.freshdesk.com/api/v2/time_entries?billable=true&executed_after=2020-02-09T00:00:00Z

Any pointers?

Hi @JoeM,

Welcome to the community! :smile::tada:

Could you attach the response received for the mentioned filtered API?
Also, can you attach the x-request-id of the request so that I can check the logs for the same or report the bug to the Freshdesk team with it?

Thanks.

Hi Raviraj

First and last part of the response below, x-request-id is: 6da35645-6405-403f-acad-d36ba44e4c78

[{
“billable”: true,
“note”: “redacted”,
“id”: redacted,
“timer_running”: false,
“agent_id”: redacted,
“ticket_id”: redacted,
“company_id”: redacted,
“time_spent”: “00:30”,
“executed_at”: “2020-09-06T23:00:00Z”,
“start_time”: “2020-09-07T08:51:20Z”,
“created_at”: “2020-09-07T08:51:20Z”,
“updated_at”: “2020-09-07T08:51:20Z”
}, {
“billable”: true,
“note”: “redacted”,
“id”: redacted,
“timer_running”: false,
“agent_id”: redacted,
“ticket_id”: redacted,
“company_id”: redacted,
“time_spent”: “00:15”,
“executed_at”: “2020-09-03T23:00:00Z”,
“start_time”: “2020-09-04T10:08:12Z”,
“created_at”: “2020-09-04T10:08:12Z”,
“updated_at”: “2020-09-04T10:08:12Z”
}, {
“billable”: true,
“note”: “”,
“id”: 43010674983,
“timer_running”: false,
“agent_id”: redacted,
“ticket_id”: redacted,
“company_id”: redacted,
“time_spent”: “00:30”,
“executed_at”: “2020-09-02T23:00:00Z”,
“start_time”: “2020-09-03T17:43:32Z”,
“created_at”: “2020-09-03T17:43:32Z”,
“updated_at”: “2020-09-03T17:43:32Z”
}, {

(snip)

}, {
“billable”: true,
“note”: “redacted”,
“id”: redacted,
“timer_running”: false,
“agent_id”: redacted,
“ticket_id”: redacted,
“company_id”: redacted,
“time_spent”: “00:30”,
“executed_at”: “2020-08-26T23:00:00Z”,
“start_time”: “2020-08-27T08:33:54Z”,
“created_at”: “2020-08-27T08:33:54Z”,
“updated_at”: “2020-08-27T08:33:54Z”
}]

@JoeM The last entry in the response that you have posted should not suppose to return for the mentioned API filter.

I’m not able to reproduce the same issue in my Freshdesk instance.
Anyway, I have reported the bug to the Freshdesk product team. I will post update after I get the response or ETA of the fix from them.

Thanks for reporting the issue. :slight_smile:

Thanks Raviraj. In the case of the response I posted, I had updated the URL to the below in the hope of just returning time entries for that day, of which I knew there was only one, but several were returned.

@JoeM The date format is starts with YYYY-MM-DD, so as per the API URL, all the time entries after Feb 9, 2020 is fetched.
It is the expected response and not a bug.

You can combine “executed_before” and “executed_after” filters to narrow down the expected results.

1 Like

Thanks for clarification on the date format, it was a rookie mistake.

The puzzling issue I saw that had me break my own date setting, was if I want to pull all the time entries for today, the 16th:

This returns nothing,

but this returns all the time entries entered on the 16th.

this returns all the time entries entered on the 15th and 16th.

It’s like the hours, minutes, seconds are being ignored…or again I’m making another nookie mistake.

Technically I could just offset my query by a day, but something feels off.

Any observations?

Could you share the response for each of these queries as well?
If the times are ignored as you have mentioned, it could be a bug and I can help report it to fix them.

curl -v -u redacted:X -X GET ‘hxxps://redacted.freshdesk.com/api/v2/time_entries?executed_after=2020-09-17T00:00:00Z&agent_id=redacted’

Headers:

Date: Thu, 17 Sep 2020 11:18:52 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
status: 200 OK
pragma: no-cache
x-request-id: 8eff0659-32dc-4f9c-9561-6a009acc1cee
x-freshdesk-api-version: latest=v2; requested=v2
x-rack-cache: miss
cache-control: must-revalidate, no-cache, no-store, private, max-age=0
x-xss-protection: 1; mode=block
x-ua-compatible: IE=Edge,chrome=1
x-content-type-options: nosniff
expires: Wed, 13 Oct 2010 00:00:00 UTC
set-cookie: _x_w=29_2; path=/; HttpOnly; secure
content-encoding: gzip
x-fw-ratelimiting-managed: true
x-ratelimit-total: 3000
x-ratelimit-remaining: 2995
x-ratelimit-used-currentrequest: 1

(no data returned)

curl -v -u redacted:X -X GET ‘hxxps://redacted.freshdesk.com/api/v2/time_entries?executed_after=2020-09-16T00:00:00Z&agent_id=redacted’

Headers:

Date: Thu, 17 Sep 2020 11:19:35 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
status: 200 OK
pragma: no-cache
x-request-id: 580260f2-649a-4c27-9290-7b92cad1c3f7
x-freshdesk-api-version: latest=v2; requested=v2
x-rack-cache: miss
cache-control: must-revalidate, no-cache, no-store, private, max-age=0
x-xss-protection: 1; mode=block
x-ua-compatible: IE=Edge,chrome=1
x-content-type-options: nosniff
expires: Wed, 13 Oct 2010 00:00:00 UTC
set-cookie: _x_w=29_2; path=/; HttpOnly; secure
content-encoding: gzip
x-fw-ratelimiting-managed: true
x-ratelimit-total: 3000
x-ratelimit-remaining: 2994
x-ratelimit-used-currentrequest: 1

Data returned:

[{
“billable”: true,
“note”: “redacted”,
“id”: 43011175937,
“timer_running”: false,
“agent_id”: redacted,
“ticket_id”: redacted,
“company_id”: null,
“time_spent”: “01:00”,
“executed_at”: “2020-09-16T23:00:00Z”,
“start_time”: “2020-09-17T11:13:16Z”,
“created_at”: “2020-09-17T11:13:16Z”,
“updated_at”: “2020-09-17T11:13:16Z”
}, {
“billable”: true,
“note”: “redacted”,
“id”: 43011169390,
“timer_running”: false,
“agent_id”: redacted,
“ticket_id”: redacted,
“company_id”: redacted,
“time_spent”: “00:15”,
“executed_at”: “2020-09-16T23:00:00Z”,
“start_time”: “2020-09-17T08:24:39Z”,
“created_at”: “2020-09-17T08:24:39Z”,
“updated_at”: “2020-09-17T08:24:39Z”
}]

curl -v -u redacted:X -X GET ‘hxxps://redacted.freshdesk.com/api/v2/time_entries?executed_after=2020-09-15T00:00:00Z&agent_id=redacted’

Headers:

Date: Thu, 17 Sep 2020 11:20:07 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
status: 200 OK
pragma: no-cache
x-request-id: e2c72ae8-7ee7-4962-8480-a8947f654a58
x-freshdesk-api-version: latest=v2; requested=v2
x-rack-cache: miss
cache-control: must-revalidate, no-cache, no-store, private, max-age=0
x-xss-protection: 1; mode=block
x-ua-compatible: IE=Edge,chrome=1
x-content-type-options: nosniff
expires: Wed, 13 Oct 2010 00:00:00 UTC
set-cookie: _x_w=29_2; path=/; HttpOnly; secure
content-encoding: gzip
x-fw-ratelimiting-managed: true
x-ratelimit-total: 3000
x-ratelimit-remaining: 2993
x-ratelimit-used-currentrequest: 1

Data returned:

[{
“billable”: true,
“note”: “redacted”,
“id”: 43011175937,
“timer_running”: false,
“agent_id”: redacted,
“ticket_id”: redacted,
“company_id”: null,
“time_spent”: “01:00”,
“executed_at”: “2020-09-16T23:00:00Z”,
“start_time”: “2020-09-17T11:13:16Z”,
“created_at”: “2020-09-17T11:13:16Z”,
“updated_at”: “2020-09-17T11:13:16Z”
}, {
“billable”: true,
“note”: “redacted”,
“id”: 43011169390,
“timer_running”: false,
“agent_id”: redacted,
“ticket_id”: redacted,
“company_id”: redacted,
“time_spent”: “00:15”,
“executed_at”: “2020-09-16T23:00:00Z”,
“start_time”: “2020-09-17T08:24:39Z”,
“created_at”: “2020-09-17T08:24:39Z”,
“updated_at”: “2020-09-17T08:24:39Z”
}, {
“billable”: true,
“note”: “redacted”,
“id”: 43011142886,
“timer_running”: false,
“agent_id”: redacted,
“ticket_id”: redacted,
“company_id”: redacted,
“time_spent”: “00:00”,
“executed_at”: “2020-09-15T23:00:00Z”,
“start_time”: “2020-09-16T16:27:06Z”,
“created_at”: “2020-09-16T16:27:06Z”,
“updated_at”: “2020-09-16T16:27:06Z”
}, {
“billable”: true,
“note”: “redacted”,
“id”: 43011142729,
“timer_running”: false,
“agent_id”: redacted,
“ticket_id”: redacted,
“company_id”: redacted,
“time_spent”: “00:45”,
“executed_at”: “2020-09-15T23:00:00Z”,
“start_time”: “2020-09-16T16:22:58Z”,
“created_at”: “2020-09-16T16:22:58Z”,
“updated_at”: “2020-09-16T16:22:58Z”
}, {
“billable”: true,
“note”: “redacted”,
“id”: 43011140759,
“timer_running”: false,
“agent_id”: redacted,
“ticket_id”: redacted,
“company_id”: redacted,
“time_spent”: “00:30”,
“executed_at”: “2020-09-15T23:00:00Z”,
“start_time”: “2020-09-16T15:34:04Z”,
“created_at”: “2020-09-16T15:34:04Z”,
“updated_at”: “2020-09-16T15:34:04Z”
}, {
“billable”: true,
“note”: “redacted”,
“id”: 43011139882,
“timer_running”: false,
“agent_id”: redacted,
“ticket_id”: redacted,
“company_id”: null,
“time_spent”: “00:15”,
“executed_at”: “2020-09-15T23:00:00Z”,
“start_time”: “2020-09-16T15:12:54Z”,
“created_at”: “2020-09-16T15:12:54Z”,
“updated_at”: “2020-09-16T15:12:54Z”
}, {
“billable”: true,
“note”: “redacted”,
“id”: 43011139692,
“timer_running”: false,
“agent_id”: 43018133830,
“ticket_id”: 65948,
“company_id”: 43001179500,
“time_spent”: “00:30”,
“executed_at”: “2020-09-15T23:00:00Z”,
“start_time”: “2020-09-16T15:08:26Z”,
“created_at”: “2020-09-16T15:08:26Z”,
“updated_at”: “2020-09-16T15:08:26Z”
}, {
“billable”: true,
“note”: “redacted”,
“id”: 43011138068,
“timer_running”: false,
“agent_id”: redacted,
“ticket_id”: redacted,
“company_id”: redacted,
“time_spent”: “00:30”,
“executed_at”: “2020-09-15T23:00:00Z”,
“start_time”: “2020-09-16T14:28:43Z”,
“created_at”: “2020-09-16T14:28:43Z”,
“updated_at”: “2020-09-16T14:46:17Z”
}, {
“billable”: true,
“note”: “redacted”,
“id”: 43011132963,
“timer_running”: false,
“agent_id”: redacted,
“ticket_id”: redacted,
“company_id”: redacted,
“time_spent”: “02:00”,
“executed_at”: “2020-09-15T23:00:00Z”,
“start_time”: “2020-09-16T12:18:24Z”,
“created_at”: “2020-09-16T12:18:24Z”,
“updated_at”: “2020-09-16T12:18:24Z”
}]