# Parse Date Error

**URL:** <https://community.make.com/t/parse-date-error/41359>\
**Category:** Questions\
**Tags:** parse, date-time-functions, error, functions\
**Created:** [June 12, 2024, 2:13am UTC](https://community.make.com/t/parse-date-error/41359 "2024-06-12T02:13:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![cre8iongroup](https://avatars.discourse-cdn.com/v4/letter/c/ac91a4/32.png) [@cre8iongroup](https://community.make.com/u/cre8iongroup)\
**Post date:** [June 12, 2024, 2:13am UTC](https://community.make.com/t/parse-date-error/41359/1 "2024-06-12T02:13:59Z")

</div>

I am trying to generate a discount rate based on the date that an item is submitted. So if it’s submitted before June 1 of Current year then it should be 50, if it’s submitted between June 1 and June 30 then it’s 25, and after June 30 it’s 0.

I had the function working with the {{now}} variable, but when I replace it with the variable for the submission date it didn’t work.

 ![Screenshot 2024-06-11 at 22.06.40](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/7/c/7c3e85d573a284853e2a98f4b5a00d13c16cef0e.jpeg)

Function with Now Variable:

```auto
{{if(now < parseDate(formatDate(now; "YYYY") + "-06-01"; "YYYY-MM-DD"); 50; if(now <= parseDate(formatDate(now; "YYYY") + "-06-30"; "YYYY-MM-DD"); 25; 0))}}

```

Function:

```auto
{{if(8.DateSubmission < parseDate(formatDate(8.DateSubmission; "YYYY") + "-06-01"; "YYYY-MM-DD"); 50; if(8.DateSubmission <= parseDate(formatDate(8.DateSubmission; "YYYY") + "-06-30"; "YYYY-MM-DD"); 25; 0))}}

```

Sample Data

```auto
[
    {
        "IDSubmission": "CwseMkNCtbvs",
        "NameCompany": "cre8ion Group",
        "NameFirst": "Corey",
        "NameLast": "Test Automation",
        "Email": "Corey@cre8iongroup.com",
        "PhoneNumber": "(989) 430-1981",
        "EmailBilling": "cre8iongroup@gmail.com",
        "Session01Type": "Workshop",
        "Session01Name": "",
        "Session01Location": "",
        "Session01Date": "",
        "Session01Package01": "($1075) - Platinum Package: Projector & screen, four (4) handheld/lavalier microphone, small sound system, and computer audio hookup.",
        "Session01Package02": "",
        "Session01Package03": "",
        "Session01ALACarte": "Two-Way Zoom ($1650)\n75'' TV Screen with stand ($2000)\nPost-it Flip Chart ($200)\nLaptop ($425)",
        "Session01Notes": "I would really like to have a cookie today",
        "Session02": "Yes",
        "Session02Type": "Information Session",
        "Session02Name": "",
        "Session02Location": "",
        "Session02Date": "",
        "Session02Package01": "",
        "Session02Package02": "($375) - Premium Package: 75\" TV with screen, two (2) handheld/lavalier microphone, sound system with mixer, and computer audio hookup.",
        "Session02Package03": "",
        "Session02ALACarte": "Two-Way Zoom ($1650)\n75'' TV Screen with stand ($2000)\nPost-it Flip Chart ($200)\nLaptop ($425)",
        "Session02Notes": "No Notes",
        "Session03": "Yes",
        "Session03Type": "Corporate Reception",
        "Session03Name": "",
        "Session03Location": "",
        "Session03Date": "",
        "Session03Package01": "",
        "Session03Package02": "",
        "Session03Package03": "($6450) Platinum Package: Sound system with mixer, 75\" TV with stand, four (4) handheld/lavalier microphone, 16 RGB Uplights - Static Colors, and computer audio hookup.",
        "Session03ALACarte": "Two-Way Zoom ($1650)\n75'' TV Screen with stand ($2000)\nPost-it Flip Chart ($200)\nLaptop ($425)",
        "Session03Notes": "No Notes",
        "Edit Link": "Edit Submission",
        "DateSubmission": "2024-05-07T12:14:31.000Z",
        " __IMTINDEX__": 1,
        " __IMTLENGTH__": 1
    }
]

```

---

<div class="post-metadata">

**Author:** ![samliew](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/samliew/32/13327_2.png) [@samliew](https://community.make.com/u/samliew)\
**Post date:** [June 12, 2024, 3:11am UTC](https://community.make.com/t/parse-date-error/41359/3 "2024-06-12T03:11:38Z")

</div>

# 1. Parsing DateSubmission into Date Type

Looks like the variable `DateSubmission` is already in a Make supported date format, but you can still parse it by using

According to the [Tokens](https://www.make.com/en/help/functions/tokens-for-date-time-formatting) you can use to format a date variable, you can use `YYYY-MM-DDTHH:mm:ss.SSSZ`.

e.g.:

`{{parseDate(105.DateSubmission; "YYYY-MM-DDTHH:mm:ss.SSSZ")}}`

 ![Screenshot_2024-06-12_110613](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/a/6/a63db1ca4ca610368bf610dfecbe4406b84e63da.png)

For more information, see Date Formats in the [Help Center](https://www.make.com/en/help).

Here are some useful links and guides you can use to learn more on how to use the Make platform, apps, and app modules. I found these useful when I was learning Make, and hope they might benefit you too —

### General

- [Help Center](https://www.make.com/en/help) | [Tutorials](https://www.make.com/en/help/tutorials.html)
- [Make Academy](https://academy.make.com) – learn Make and get your certificate
- [Discord Server](https://samliew.com/make-discord-invite) – join us in live chat for fans of Make!

### Help Center Basics

- [Mapping](https://www.make.com/en/help/mapping/mapping) – What is mapping? What can I map?
- [Mapping with arrays](https://www.make.com/en/help/mapping/mapping-arrays) – How to map items in an array
- [Aggregate an array for mapping complex fields](https://www.make.com/en/help/tools/flow-control#customizing-the-output)
- [Tokens for `parseDate`](https://www.make.com/en/help/functions/tokens-for-date-time-parsing) | [Tokens for `formatDate`](https://www.make.com/en/help/functions/tokens-for-date-time-formatting)
- [HTTP modules](https://www.make.com/en/help/tools/http) – Make a request, Get (download) a file
- [Webhooks](https://www.make.com/en/help/tools/webhooks) – Error Handling, Responding to webhooks

### Articles & Videos

- [Router Magic Formula](https://www.youtube.com/watch?v=4Q-5BsCtJu4) - YouTube
- [Error Handlers in Make](https://www.youtube.com/playlist?list=PLRE9E-rAD8U10mx2TRs54Nq1XJDdK9Kx4) - YouTube playlist
- [Getting started with OpenAI](https://community.make.com/t/getting-started-with-openai-gpt-3-and-make/7796)
- [How to use Regex in Make](https://community.make.com/t/how-to-use-regex-in-make/202)

[samliew](https://samliew.com/services) – [request private consultation](https://samliew.com/request-quote?ServiceType=Automation%20Consultation&Referrer=Make)

> Join the unofficial [Make Discord server](https://samliew.com/make-discord-invite) to chat with other makers!

---

<div class="post-metadata">

**Author:** ![samliew](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/samliew/32/13327_2.png) [@samliew](https://community.make.com/u/samliew)\
**Post date:** [June 12, 2024, 3:18am UTC](https://community.make.com/t/parse-date-error/41359/4 "2024-06-12T03:18:53Z")

</div>

# 2. Get Middle of Year

You can get the “middle” of the year (30 June at 23:59) by either of these two methods:

 ![Screenshot_2024-06-12_110642](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/6/c/6c2a0b361e74a86d711cdc985ad6e3d9899920ed.png)

```plaintext
{{setSecond(setMinute(setHour(setDate(setMonth(now; 6); 30); 23); 59); 59)}}

```

```plaintext
{{parseDate("30-06-" + formatDate(now; "YYYY") + " 23:59:59"; "DD-MM-YYYY HH:mm:ss")}}

```

**Output**

 ![Screenshot_2024-06-12_110629](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/9/c/9cebdf91a9dfe3aa80a254f39517bc6e27bb8e86.png)

[samliew](https://samliew.com/services) – [request private consultation](https://samliew.com/request-quote?ServiceType=Automation%20Consultation&Referrer=Make)

> ### Join the [Make Fans](https://samliew.com/make-discord-invite) Discord server to [chat](https://samliew.com/make-discord-invite) with other makers!

---

<div class="post-metadata">

**Author:** ![samliew](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/samliew/32/13327_2.png) [@samliew](https://community.make.com/u/samliew)\
**Post date:** [June 12, 2024, 3:28am UTC](https://community.make.com/t/parse-date-error/41359/5 "2024-06-12T03:28:40Z")

</div>

# 3. Check if before July

Combining step 1 and 2, adding a less-than operator in-between:

 ![Screenshot_2024-06-12_110640](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/1/5/15edaf3f189ab2e0707a7560e86890b3dd1c572c.png)

# 4. Wrap your if-statement

 ![Screenshot_2024-06-12_110640 - Copy](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/5/7/576c9782d46f8a080ab61d0355b294d7749c752e.png)

**Output**

 ![Screenshot_2024-06-12_110606](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/9/8/9895223df12fe48e7ea2eecc8ae1eccb9aac4fa3.png)

[samliew](https://samliew.com/services) – [request private consultation](https://samliew.com/request-quote?ServiceType=Automation%20Consultation&Referrer=Make)

> ### Join the [Make Fans](https://samliew.com/make-discord-invite) Discord server to [chat](https://samliew.com/make-discord-invite) with other makers!

---

<div class="post-metadata">

**Author:** ![samliew](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/samliew/32/13327_2.png) [@samliew](https://community.make.com/u/samliew)\
**Post date:** [June 12, 2024, 3:30am UTC](https://community.make.com/t/parse-date-error/41359/6 "2024-06-12T03:30:49Z")

</div>

## Module Export

You can **copy** and **paste** this module export into your scenario. This will paste the modules shown in my screenshots above.

1. Copy the JSON code below by clicking the copy button when you mouseover the **top-right** of the code block  
 ![Screenshot_2024-01-17_200117](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/2/b/2b1b692880388420db5045bf51ef344e6698a816.png)

2. Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV (paste keyboard shortcut for Windows) to paste directly in the canvas.

3. Click on each imported module and save it for validation. You may be prompted to remap some variables and connections.

> **View Module Export Code**
>
> #### JSON
> 
> ```json
> {
> "subflows": [
> {
> "flow": [
> {
> "id": 105,
> "module": "util:SetVariable2",
> "version": 1,
> "parameters": {},
> "mapper": {
> "name": "DateSubmission",
> "scope": "roundtrip",
> "value": "2024-05-07T12:14:31.000Z"
> },
> "metadata": {
> "designer": {
> "x": -2030,
> "y": 291,
> "name": "Set Date String"
> },
> "restore": {
> "expect": {
> "scope": {
> "label": "One cycle"
> }
> }
> },
> "expect": [
> {
> "name": "name",
> "type": "text",
> "label": "Variable name",
> "required": true
> },
> {
> "name": "scope",
> "type": "select",
> "label": "Variable lifetime",
> "required": true,
> "validate": {
> "enum": [
> "roundtrip",
> "execution"
> ]
> }
> },
> {
> "name": "value",
> "type": "any",
> "label": "Variable value"
> }
> ],
> "interface": [
> {
> "name": "DateSubmission",
> "label": "DateSubmission",
> "type": "any"
> }
> ]
> }
> },
> {
> "id": 107,
> "module": "util:SetVariables",
> "version": 1,
> "parameters": {},
> "mapper": {
> "variables": [
> {
> "name": "ParsedDate",
> "value": "{{parseDate(105.DateSubmission; \"YYYY-MM-DDTHH:mm:ss.SSSZ\")}}"
> },
> {
> "name": "MiddleOfYear",
> "value": "{{setSecond(setMinute(setHour(setDate(setMonth(now; 6); 30); 23); 59); 59)}}"
> },
> {
> "name": "MiddleOfYearAlt",
> "value": "{{parseDate(\"30-06-\" + formatDate(now; \"YYYY\") + \" 23:59:59\"; \"DD-MM-YYYY HH:mm:ss\")}}"
> },
> {
> "name": "IsBeforeJuly",
> "value": "{{parseDate(105.DateSubmission; \"YYYY-MM-DDTHH:mm:ss.SSSZ\") < \"\n\"}}{{parseDate(\"30-06-\" + formatDate(now; \"YYYY\") + \" 23:59:59\"; \"DD-MM-YYYY HH:mm:ss\")}}"
> },
> {
> "name": "DiscountRate",
> "value": "{{if(parseDate(105.DateSubmission; \"YYYY-MM-DDTHH:mm:ss.SSSZ\") < parseDate(\"30-06-\" + formatDate(now; \"YYYY\") + \" 23:59:59\"; \"DD-MM-YYYY HH:mm:ss\"); 25; 0)}}"
> }
> ],
> "scope": "roundtrip"
> },
> "metadata": {
> "designer": {
> "x": -1785,
> "y": 290,
> "name": "Check if before July"
> },
> "restore": {
> "expect": {
> "variables": {
> "items": [
> null,
> null,
> null,
> null,
> null
> ]
> },
> "scope": {
> "label": "One cycle"
> }
> }
> },
> "expect": [
> {
> "name": "variables",
> "type": "array",
> "label": "Variables",
> "spec": [
> {
> "name": "name",
> "label": "Variable name",
> "type": "text",
> "required": true
> },
> {
> "name": "value",
> "label": "Variable value",
> "type": "any"
> }
> ]
> },
> {
> "name": "scope",
> "type": "select",
> "label": "Variable lifetime",
> "required": true,
> "validate": {
> "enum": [
> "roundtrip",
> "execution"
> ]
> }
> }
> ],
> "interface": [
> {
> "name": "ParsedDate",
> "label": "ParsedDate",
> "type": "any"
> },
> {
> "name": "MiddleOfYear",
> "label": "MiddleOfYear",
> "type": "any"
> },
> {
> "name": "MiddleOfYearAlt",
> "label": "MiddleOfYearAlt",
> "type": "any"
> },
> {
> "name": "IsBeforeJuly",
> "label": "IsBeforeJuly",
> "type": "any"
> },
> {
> "name": "DiscountRate",
> "label": "DiscountRate",
> "type": "any"
> }
> ]
> }
> }
> ]
> }
> ],
> "metadata": {
> "version": 1
> }
> }
> 
> ```

Here are some useful links and guides you can use to learn more on how to use the Make platform, apps, and app modules. I found these useful when I was learning Make, and hope they might benefit you too —

### General

- [Help Center](https://www.make.com/en/help) | [Tutorials](https://www.make.com/en/help/tutorials.html)
- [Make Academy](https://academy.make.com) – learn Make and get your certificate
- [Discord Server](https://samliew.com/make-discord-invite) – join us in a community-run live chat

### Help Center Basics

- [Mapping](https://www.make.com/en/help/mapping/mapping) – What is mapping? What can I map?
- [Mapping with arrays](https://www.make.com/en/help/mapping/mapping-arrays) – How to map items in an array
- [Aggregate an array for mapping complex fields](https://www.make.com/en/help/tools/flow-control#customizing-the-output)
- [Tokens for `parseDate`](https://www.make.com/en/help/functions/tokens-for-date-time-parsing) | [Tokens for `formatDate`](https://www.make.com/en/help/functions/tokens-for-date-time-formatting)
- [HTTP modules](https://www.make.com/en/help/tools/http) – Make a request, Get (download) a file
- [Webhooks](https://www.make.com/en/help/tools/webhooks) – Error Handling, Responding to webhooks

### Articles & Videos

- [Router Magic Formula](https://www.youtube.com/watch?v=4Q-5BsCtJu4) - YouTube
- [Error Handlers in Make](https://www.youtube.com/playlist?list=PLRE9E-rAD8U10mx2TRs54Nq1XJDdK9Kx4) - YouTube playlist
- [Getting started with OpenAI](https://community.make.com/t/getting-started-with-openai-gpt-3-and-make/7796)
- [How to use Regex in Make](https://community.make.com/t/how-to-use-regex-in-make/202)

[samliew](https://samliew.com/services) – [request private consultation](https://samliew.com/request-quote?ServiceType=Automation%20Consultation&Referrer=Make)

> ### Join the [Make Fans](https://samliew.com/make-discord-invite) Discord server to [chat](https://samliew.com/make-discord-invite) with other makers!

---

<div class="post-metadata">

**Author:** ![cre8iongroup](https://avatars.discourse-cdn.com/v4/letter/c/ac91a4/32.png) [@cre8iongroup](https://community.make.com/u/cre8iongroup)\
**Post date:** [June 12, 2024, 10:47am UTC](https://community.make.com/t/parse-date-error/41359/7 "2024-06-12T10:47:44Z")

</div>

_ **Edit:** _ I did still have to use a Parse date function to get this to work. I’m assuming it is because it was treating it as text and not as an actual date even though it works in other places. I’ve updated the code. I had to Parse all of dates (DateSubmission, Discount01End, and Discount02End). The discount dates I parsed in the set variable before this module.

_ **Updated Code:** _

```auto
{{if(parseDate(8.DateSubmission; "YYYY-MM-DDTHH:mm:ss.SSSZ") < 36.Discount01End; 50; if(parseDate(8.DateSubmission; "YYYY-MM-DDTHH:mm:ss.SSSZ") < 36.Discount02End; 25; 0))}}

```

_ **Original Message** _

@samliew Thank you for your help! I ended up simplifying it further. The whole goal with the scenario has been to use variables so I can quickly reuse this next year with that in mind and what you said about the dates already being in an acceptable format. I replaced the Parse and Format date with a variable from a set of Variables earlier that sets the two due dates.

 ![Screenshot 2024-06-12 at 06.45.11](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/7/9/79e57a50757a22040a35d1def52e920f68070e38.png)

I’ve included the code I ended up using for anyone’s reference later on.

```auto
{{if(8.DateSubmission < 36.Discount01End; 50; if(8.DateSubmission < 36.Discount02End; 25; 0))}}

```

---

<div class="post-metadata">

**Author:** ![Make\_Bot](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/make_bot/32/14661_2.png) [@Make\_Bot](https://community.make.com/u/Make_Bot)\
**Post date:** [June 26, 2024, 10:49am UTC](https://community.make.com/t/parse-date-error/41359/8 "2024-06-26T10:49:09Z")

</div>


