After using a formatDate function we got a wrong date

Hi the community,

We are creating a workflow with the calendly module to create a new opportunity on our CRM.

We are looking to match the date format ask by our CRM and for this, we are using this function :

{ "date": "{{formatDate(parseDate(1.scheduled_event.start_time; "D MMMM YYYY HH:mm"); "YYYY-MM-DDTHH:MM:SSZZ")}}" }

the value of 1.scheduled_event.start_time is 4 avril 2024 11:30

But at the end, we got this result : {"date": "2024-04-04T11:04:00+02:00"}, so 4 avril at 11h04.

Do we make something wrong ?

—

Hi @LEGRAND,

Welcome to the Make Community :partying_face:

If you hover over your field from Calendly, does it show as a date or string (text) - see red underlined?

image

This makes a difference if you need to use formatDate() or parseDate() . formatDate works on a date value, parseDate is for text/string values.

2 Likes

Hi @NolaDigital,

The field date is a Date type.

But I clean the function like this : "date": "{{formatDate(1.scheduled_event.start_time; "YYYY-MM-DDTHH:MM:SSZ")}}",

Now, we have the right hour, but with 4 more minutes, like 10h04 instead of 10h00.

Okay, what date format does your CRM expect?

If it is a date field coming from Calendly, there’s a good chance it’ll be in ISO-8601 (UTC time) time format. Make will show it as human readable in the output, but if you hover over the output value, you’ll see the “raw” value.
image

You can also click on the Download output bundles and see the raw value there.
image
image

So if that’s a time format your CRM can work with, you don’t have to convert it. If they would need a more standard DD-MM-YYYY HH:MM format (like 29-03-2024 12:15) you would need to convert it like this:

image

{{formatDate(1.inputTime; "DD-MM-YYYY HH:MM")}}

image

2 Likes

Thanks a lot for all explanation @NolaDigital :slight_smile:
I succeeded.

3 Likes