Google Calendar - Start Date flipping days/months

Hello, I’ve been working on creating new events on a Google Calendar from Make. However, I have used multiple date formats, and I keep getting a very frustrating problem. My current date format is US-standard MM-DD-YYYY. Example 10-31-2024 will create an event on October 31st, 2024. But 10-03-2024 will create an event on March 3rd, 2024! I can’t figure out the “correct” date format for the Start Date and End Date parameters. It seems like it is looking for a valid date in DD-MM-YYYY format and then if it doesn’t return a valid date there, it switches to MM-DD-YYYY. What’s the right away to do this?

Here’s my “code”:
{{formatDate(21.MyAvailability[36.ItemNumber].StartingDate; “MM-DD-YYYY”)}} {{substring(21.MyAvailability[36.ItemNumber].StartTime; 0; 5)}}

1 Like

It’s because Make is not interpreting your variable as a date, but as a string. So when you use formatDate(“your string”) it tries to see if it’s DD-MM-YYYY (the standard American format) and if so, it keeps it. If it doesn’t work, it tries MM-DD-YYYY.

To fix that, you can use this:

{{formatDate(parseDate(1.date1; “MM-DD-YYYY”); “MM-DD-YYYY”)}}

Notice how there is a parseDate in there first, to parse it correctly in the date format you expect.

L

2 Likes

Hi @samv
There should not be any inverted comma,


Best regards,

Msquare Automation
Gold Partner of Make
@Msquare_Automation

1 Like

Hi, guys, I’m still getting this error even after adding parsedate. Here’s my code:
Start Date: formatDate(parseDate(21. MyAvailability.StartingDate;YYYY-MM-DD);MM-DD-YYYY) substring(21. MyAvailability.StartTime;0;5

I’m also attaching my input/output bundles.
Input and output bundles.pdf (79.1 KB)

Are you parsing the correct thing? I thought you were parsing “10-03-2024” but it seems you’re parsing “2024-04-11T23:00:00.000Z” or something else I’m not seeing. Unless I’m mistaken, you need to tell the parser the exact format of your date (including the timezone in this case).

If I’m misunderstanding, I recommend you create a test scenario where you put in a Set Variable module where you put the exact data you’re having problems with and then share that scenario. It should be easier to debug.

L