# How to get weekly data for Tasks through Graphql

**URL:** <https://community.hubspot.com/t/how-to-get-weekly-data-for-tasks-through-graphql/88264>\
**Category:** APIs & Integrations\
**Tags:** integrations, developer, file-manager, crm, tasks, sales\
**Created:** [August 24, 2023, 4:54pm UTC](https://community.hubspot.com/t/how-to-get-weekly-data-for-tasks-through-graphql/88264 "2023-08-24T16:54:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Priya07](https://avatars.discourse-cdn.com/v4/letter/p/b5ac83/32.png) [@Priya07](https://community.hubspot.com/u/Priya07)\
**Post date:** [August 24, 2023, 4:54pm UTC](https://community.hubspot.com/t/how-to-get-weekly-data-for-tasks-through-graphql/88264/1 "2023-08-24T16:54:10Z")

</div>

Hi All,

Can anyone please me that how to get weekly data for task which will be filter by Due date.

Example:

Tasks: [Screenshot by Lightshot](https://prnt.sc/6O2vqjg4iwhh)

Graphql: [Screenshot by Lightshot](https://prnt.sc/IjhES64HLVrd)

I am not able to find filter in Graphql list. Here is the exampl of code:

{% for test in taskCollectionData %}

{{test.hs\_task\_subject}}

{% endfor %}

Above condition is working fine but I need weekly data indead of all the task list.

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![ChrisoKlepke](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/chrisoklepke/32/11213_2.png) [@ChrisoKlepke](https://community.hubspot.com/u/ChrisoKlepke)\
**Post date:** [August 28, 2023, 12:29pm UTC](https://community.hubspot.com/t/how-to-get-weekly-data-for-tasks-through-graphql/88264/2 "2023-08-28T12:29:31Z")

</div>

Hey @Priya07 ,

thank you for reaching out to the community.

Maybe I can help a little here. When you want to filter all tasks for each week, you need to find the timestamp for Monday 12am for your timezone first. After that, you need to use that timestamp in your query. For me, it looks something like this:

```lia-code-sample
query MyQuery {
 CRM {
 task_collection(filter: {hs_createdate__gte: "1693180800000"}) {
 items {
 hs_createdate
 hs_object_id
 hs_task_subject
 }
 }
 }
}

```

Let us know if this helps.

Cheers,

Chriso

---

<div class="post-metadata">

**Author:** ![Priya07](https://avatars.discourse-cdn.com/v4/letter/p/b5ac83/32.png) [@Priya07](https://community.hubspot.com/u/Priya07)\
**Post date:** [August 28, 2023, 12:37pm UTC](https://community.hubspot.com/t/how-to-get-weekly-data-for-tasks-through-graphql/88264/3 "2023-08-28T12:37:44Z")

</div>

Hi @ChrisoKlepke ,

Thanks for sharing above solution.

I need to use UK timezone for weekly data. Can you help me with this please?

Best regards,

Priya

---

<div class="post-metadata">

**Author:** ![ChrisoKlepke](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/chrisoklepke/32/11213_2.png) [@ChrisoKlepke](https://community.hubspot.com/u/ChrisoKlepke)\
**Post date:** [August 28, 2023, 12:50pm UTC](https://community.hubspot.com/t/how-to-get-weekly-data-for-tasks-through-graphql/88264/4 "2023-08-28T12:50:00Z")

</div>

Hey,

you can look for this yourself and experiment with it [here.](https://www.unixtimestamp.com/)

For this week, in GMT+1 it would be 1693226642. HubSpot works in milliseconds, so you have to add some zeros at the end. So 1693226642000

You very likely need to have a function looking for the respective Monday midnight time. Depending on what you’re building, there is very likely a library for that.

Make sure you filter on due date. In my example, I used _create\_date. Sorry about that._

If you found this post helpful, consider helping others in the community to find answers faster by marking this as a solution. I’d really appreciate it.

Cheers,

Chriso

---

<div class="post-metadata">

**Author:** ![Priya07](https://avatars.discourse-cdn.com/v4/letter/p/b5ac83/32.png) [@Priya07](https://community.hubspot.com/u/Priya07)\
**Post date:** [August 29, 2023, 9:15am UTC](https://community.hubspot.com/t/how-to-get-weekly-data-for-tasks-through-graphql/88264/5 "2023-08-29T09:15:05Z")

</div>

```lia-code-sample
query MyQuery {
 CRM {
 task_collection(orderBy: hs_timestamp __desc, limit: 5000, filter: {hubspot_owner_id__ eq: "XXXXXXXX",hs_createdate__gte: "1693226642000"}) {
 items {
 hs_task_subject
 }
 }
 }
}

```

Hi @ChrisoKlepke ,

I tried with above code which you are provided but it doesn’t work for me:

Could you please look into this.

Thanks in advance!

Priya

---

<div class="post-metadata">

**Author:** ![ChrisoKlepke](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/chrisoklepke/32/11213_2.png) [@ChrisoKlepke](https://community.hubspot.com/u/ChrisoKlepke)\
**Post date:** [August 30, 2023, 7:04am UTC](https://community.hubspot.com/t/how-to-get-weekly-data-for-tasks-through-graphql/88264/6 "2023-08-30T07:04:27Z")

</div>

Hey @Priya07

Can you get into more detail where you’re at and what doesn’t work precisely? It is very hard for us in the community to diagnose problems remotely already, but if you provide the most information possible, we can usually work out something. That is especially true for development stuff.

Looking forward hearing from you.

Cheers,

Chriso

---

<div class="post-metadata">

**Author:** ![Priya07](https://avatars.discourse-cdn.com/v4/letter/p/b5ac83/32.png) [@Priya07](https://community.hubspot.com/u/Priya07)\
**Post date:** [September 1, 2023, 1:06pm UTC](https://community.hubspot.com/t/how-to-get-weekly-data-for-tasks-through-graphql/88264/7 "2023-09-01T13:06:28Z")

</div>

Hi @ChrisoKlepke ,

Thanks for your response.

Here is the below code which I used for graphql file:

```lia-code-sample
query CombinedQueries {
CRM {
task_collection(orderBy: hs_timestamp __desc, limit: 5000, filter: {hubspot_owner_id__ eq: "XXXXXXXX"}) {
items {
hs_task_priority
hs_task_body
hs_task_subject
hs_timestamp
hs_task_type
hs_task_status
}
}
meeting_event_collection(orderBy: hs_meeting_start_time __desc, limit: 50, filter: {hubspot_owner_id__ eq: "XXXXXXX"}) {
items {
hs_activity_type
hs_meeting_start_time
hs_meeting_title
hs_meeting_outcome
}
}
}
}

```

Output: [https://prnt.sc/Oei5qbX\_bhJP](https://prnt.sc/Oei5qbX_bhJP)  
Expectation: [Screenshot by Lightshot](https://prnt.sc/wuMBmIs9e0WZ)

This output provided all data but I need weekly data for tasks filter by due date.

Let me know if you need anything.

Thanks in advance!

Priya
