We use cookies to make HubSpot's community a better place. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. To learn more, and to see a full list of cookies we use, check out our Cookie Policy (baked goods not included).
Jun 12, 2019 11:48 AM
I am attempting to update a filter daily, using the Java API.
The field is a date field, called membership_end_date.
When I attempt to do this using java, I get this error message:
Dates with greater than filters must specify the end of the day as the timestamp
My date, in milliseconds, is set to the end of the current day:
1560398399999
Which, in plain text, is...
Wed Jun 12 23:59:59 EDT 2019
Here is my JSON:
{ "name": "Active Members List", "filters": [ [ { "withinTimeMode": "PAST", "filterFamily": "PropertyValue", "property": "membership_end_date", "type": "date", "value": 1560398399999, "operator": "IS_NOT_EMPTY" }, { "withinTimeMode": "PAST", "filterFamily": "PropertyValue", "property": "membership_end_date", "type": "date", "value": 1560398399999, "operator": "GT" }, { "withinTimeMode": "PAST", "filterFamily": "PropertyValue", "property": "current_membership", "type": "string", "value": "Membership", "operator": "CONTAINS" } ] ] }
Solved! Go to Solution.
Jun 14, 2019 12:53 PM
I'm generating this timestamp with Java.
1560571199999 Fri Jun 14 23:59:59 EDT 2019
Also, 1560398399999 comes out to Wed 12 June 2019
23:59:59 when I use an online date converter.
Check your numbers again?
Jun 14, 2019 1:28 PM
Hi, @mclayton.
My numbers are correct. You must use a timestamp that reflects 23:59:59.999 in UTC/GMT 0:00 on the desired date, not 23:59:59.999 in your local time zone (e.g. EDT,or UTC -4:00).
When I attempt to update one of my own list filters with the EDT timestamp 1560916799999
(Tuesday, June 18, 2019 at 23:59:59.999 EDT):
{ "filters": [ [ { "withinTimeMode": "PAST", "operator": "GT", "filterFamily": "PropertyValue", "type": "date", "property": "custom_date_picker", "value": 1560916799999 } ] ] }
... I receive the following error:
{ "status": "error", "message": "Dates with greater than filters must specify the end of the day as the timestamp", "correlationId": "fb2eba9a-6015-427c-9989-7cbeae9fced0", "requestId": "eda7e04e7010e7959ae4ad6cce1d39a1" }
However, when I use a timestamp reflecting Tuesday, June 18, 2019 at 23:59:59.999 in the UTC/GMT time zone — 1560902399999
:
{ "filters": [ [ { "withinTimeMode": "PAST", "operator": "GT", "filterFamily": "PropertyValue", "type": "date", "property": "custom_date_picker", "value": 1560902399999 } ] ] }
...I receive a 200
response and the update takes.
Isaac TakushiAssociate Certification Manager |
Jun 12, 2019 5:10 PM
Hi, @mclayton.
HubSpot accepts epoch timestamps in UTC (0:00), so I think the issue is that 1560398399999
comes out to Thursday, June 13, 2019 at 03:59:59.999 UTC.
Could you try 1560383999999
?
Isaac TakushiAssociate Certification Manager |
Jun 14, 2019 2:28 PM - edited Jun 14, 2019 2:33 PM
Seems to be working.
Only thing I did differently was to setTimeZone(......)
Thanks @IsaacTakushi
Date day = new Date(); Calendar cal = Calendar.getInstance(); cal.setTime(day); cal.set(Calendar.HOUR_OF_DAY, cal.getMaximum(Calendar.HOUR_OF_DAY)); cal.set(Calendar.MINUTE, cal.getMaximum(Calendar.MINUTE)); cal.set(Calendar.SECOND, cal.getMaximum(Calendar.SECOND)); cal.set(Calendar.MILLISECOND, cal.getMaximum(Calendar.MILLISECOND)); cal.setTimeZone(TimeZone.getTimeZone("UTC"));
Jun 14, 2019 12:53 PM
I'm generating this timestamp with Java.
1560571199999 Fri Jun 14 23:59:59 EDT 2019
Also, 1560398399999 comes out to Wed 12 June 2019
23:59:59 when I use an online date converter.
Check your numbers again?
Jun 14, 2019 1:28 PM
Hi, @mclayton.
My numbers are correct. You must use a timestamp that reflects 23:59:59.999 in UTC/GMT 0:00 on the desired date, not 23:59:59.999 in your local time zone (e.g. EDT,or UTC -4:00).
When I attempt to update one of my own list filters with the EDT timestamp 1560916799999
(Tuesday, June 18, 2019 at 23:59:59.999 EDT):
{ "filters": [ [ { "withinTimeMode": "PAST", "operator": "GT", "filterFamily": "PropertyValue", "type": "date", "property": "custom_date_picker", "value": 1560916799999 } ] ] }
... I receive the following error:
{ "status": "error", "message": "Dates with greater than filters must specify the end of the day as the timestamp", "correlationId": "fb2eba9a-6015-427c-9989-7cbeae9fced0", "requestId": "eda7e04e7010e7959ae4ad6cce1d39a1" }
However, when I use a timestamp reflecting Tuesday, June 18, 2019 at 23:59:59.999 in the UTC/GMT time zone — 1560902399999
:
{ "filters": [ [ { "withinTimeMode": "PAST", "operator": "GT", "filterFamily": "PropertyValue", "type": "date", "property": "custom_date_picker", "value": 1560902399999 } ] ] }
...I receive a 200
response and the update takes.
Isaac TakushiAssociate Certification Manager |