APIs & Integrations

WBowman
Participant

Updating field type from Date to Date Time

SOLVE

Hi, I am updating a date field to a date time field via the properties API.  One thing I've noticed is that when I make the update, the value in the field is changing to the day before. 

 

Date field value (mm/dd/yyyy): 12/15/2024

Date Time field value (mm/dd/yyyy): 12/14/2024 8:00 PM

 

This looks to be happening because my time zone is -4 hours from UTC.  I'm wondering if there is a way to prevent this, so that the value just updates to midnight and keeps the same date?

2 Accepted solutions
GRajput
Solution
Recognized Expert | Gold Partner
Recognized Expert | Gold Partner

Updating field type from Date to Date Time

SOLVE

Hi @WBowman 

 

dateString = '12/15/2024'; // MM/DD/YYYY
date = new Date(dateString);
original timestamp = date.valueOf();
adjustedTimestamp = original timestamp - (4 * 60 * 60 * 1000);
now send this adjusted timestamp as a new property value in HubSpot.
This should update the date with -4 hours time difference.

 

 

I hope this will help you out. Please mark it as Solution Accepted and upvote to help another Community member.
Thanks!

 




Gaurav Rajput
Director, MarTech( Growth Natives)

Book a meeting


View solution in original post

Bortami
Solution
Top Contributor | Elite Partner
Top Contributor | Elite Partner

Updating field type from Date to Date Time

SOLVE

You would need to send a separate call to each record after you made the field type change.

 

If you have Ops Hub Pro, you could automate updating the time with a custom coded action using @GRajput 's code.

 

Otherwise, the quickest way to update would be to export to excel and reupload.

View solution in original post

0 Upvotes
5 Replies 5
Bortami
Solution
Top Contributor | Elite Partner
Top Contributor | Elite Partner

Updating field type from Date to Date Time

SOLVE

You would need to send a separate call to each record after you made the field type change.

 

If you have Ops Hub Pro, you could automate updating the time with a custom coded action using @GRajput 's code.

 

Otherwise, the quickest way to update would be to export to excel and reupload.

0 Upvotes
WBowman
Participant

Updating field type from Date to Date Time

SOLVE

Hi @GRajput, thanks for the reply. Is there a way to do this when I'm updating the property type via the API from date to datetime, so that it just automatically applies to all values or would I need to do a seperate call to update the record values? If it's the latter, I'm thinking the easiest way may be to just export all records in a csv, use a formula to update the values with the proper offset and then import. 

GRajput
Solution
Recognized Expert | Gold Partner
Recognized Expert | Gold Partner

Updating field type from Date to Date Time

SOLVE

Hi @WBowman 

 

dateString = '12/15/2024'; // MM/DD/YYYY
date = new Date(dateString);
original timestamp = date.valueOf();
adjustedTimestamp = original timestamp - (4 * 60 * 60 * 1000);
now send this adjusted timestamp as a new property value in HubSpot.
This should update the date with -4 hours time difference.

 

 

I hope this will help you out. Please mark it as Solution Accepted and upvote to help another Community member.
Thanks!

 




Gaurav Rajput
Director, MarTech( Growth Natives)

Book a meeting


GRajput
Recognized Expert | Gold Partner
Recognized Expert | Gold Partner

Updating field type from Date to Date Time

SOLVE

Hi @WBowman 

 

what you can do is add the time differnce in the date you update.
for ex; corrected time = originalDate + timezone offset (in hours) which I believe is 4 hours in your case so it will look like this
"property": "2024-12-15T04:00:00Z"

 

I hope this will help you out. Please mark it as Solution Accepted and upvote to help another Community member.
Thanks!




Gaurav Rajput
Director, MarTech( Growth Natives)

Book a meeting


BérangèreL
Community Manager
Community Manager

Updating field type from Date to Date Time

SOLVE

Hi @WBowman, I hope that you are well!

Thanks for asking the HubSpot Community!

Let's check with our Top Experts: Hi @sylvain_tirreau, @zach_threadint and @Bortami do you experience the same as @WBowman when using date time field, please? Do you have tips to help @WBowman, please?

Have a lovely day and thanks so much in advance for your help!
Bérangère


HubSpot’s AI-powered customer agent resolves up to 50% of customer queries instantly, with some customers reaching up to 90% resolution rates.
Learn More.


Saviez vous que la Communauté est disponible en français?
Rejoignez les discussions francophones en changeant votre langue dans les paramètres! !
0 Upvotes