# Last Date in object custom

**URL:** <https://community.hubspot.com/t/last-date-in-object-custom/103319>\
**Category:** APIs & Integrations\
**Tags:** developer-tools\
**Created:** [March 25, 2024, 12:19pm UTC](https://community.hubspot.com/t/last-date-in-object-custom/103319 "2024-03-25T12:19:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![CarolineFscs](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/carolinefscs/32/36994_2.png) [@CarolineFscs](https://community.hubspot.com/u/CarolineFscs)\
**Post date:** [March 25, 2024, 12:19pm UTC](https://community.hubspot.com/t/last-date-in-object-custom/103319/1 "2024-03-25T12:19:52Z")

</div>

**Hi guys, what’s up?**

It’s possible to extract the maximum date of a date property from a given property’s unique value. Would this be done through custom code?

Example: I have 3 different records of customized objects, but they have a property of the same value, equal, and another date property that are different, I would like to extract the maximum date of these 3 records.

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [March 26, 2024, 7:01pm UTC](https://community.hubspot.com/t/last-date-in-object-custom/103319/2 "2024-03-26T19:01:55Z")

</div>

Hey, @CarolineFscs 👋 Thanks for the interesting question. I do not believe there is a single simple solution for this one. You have a few options, including:

Custom code and our APIs:

- Retrieve the Records using the [Custom object endpoints](https://developers.hubspot.com/docs/api/crm/crm-custom-objects) using query params to filter based on your unique property value
- Filter and sort using custom code

Look at [Custom Code Actions](https://developers.hubspot.com/docs/api/workflows/custom-code-actions):

- Write a script using JavaScript or Python
- Fetch your records
- Apply filtering and maximum date logic
- And, possibly, update a record or trigger another action

If you have developer resources, you can set up [Developer Test account](https://developers.hubspot.com/docs/api/account-types#developer-test-accounts) to test this outside of your production portal.

Best,

Jaycee

---

<div class="post-metadata">

**Author:** ![CarolineFscs](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/carolinefscs/32/36994_2.png) [@CarolineFscs](https://community.hubspot.com/u/CarolineFscs)\
**Post date:** [March 26, 2024, 7:27pm UTC](https://community.hubspot.com/t/last-date-in-object-custom/103319/3 "2024-03-26T19:27:26Z")

</div>

Jaycee, I followed this path but it didn’t work because the return is {‘total’: 0, ‘results’: []}

```lia-code-sample
import requests 

headers = {
 'authorization': 'key',
 'Content-Type': 'application/json'
}

def main(event):
 dataresposta = getDataResposta()
 print(dataresposta)

def getDataResposta():
 requestUrl = 'https://api.hubapi.com/crm/v3/objects/2-25689014/search'
 data = {
 "filterGroups": [
 {
 "filters": [
 {
 "value": "companyid",
 "propertyName": "companyid",
 "operator": "EQ"
 },
 {
 "value": "NPS - Produto",
 "propertyName": "pesquisa",
 "operator": "EQ"
 }
 ]
 }
 ],
 "properties": [
 "data_resposta"
 ],
 "sorts": [
 {
 "propertyName": "data_resposta",
 "direction": "DESCENDING"
 }
 ],
 "limit": 1
 }
 response = requests.post(requestUrl, headers=headers, json=data)
 return response.json()

```
