Date is not getting formatted correctly, how to remove time?

Hi,
I need the day field in format YYYY-MM-DD. But I always get something with time returned. Also I played a bit around with setting a time like in middle of the the so the date is not changed, but often it seems to return the wrong date… Also tried parseDate but had no success…

Here are the screenshots from one of my tries:

Module



Input

Output

if I leave the date field empty I can get all the items… see following screenshot. so the api is working. but I am trying to get as an example the item Bundle 502 in the screenshot. There you can see day is 2024-08-20. But I can get nothing.

How to achieve this?

Btw in the api description of the application (Marvin API · amazingmarvin/MarvinAPI Wiki · GitHub) there is written :

Time zone issues are possible here (the server is UTC+0), so it's best to provide a date. This can either be done using a query parameter or the X-Date header. In both cases, use the date format "YYYY-MM-DD".

GET /api/todayItems?date=2021-11-15
X-API-Token: XYZ
=>
[...]
OR

GET /api/todayItems
X-API-Token: XYZ
X-Date: 2021-11-15
=>
[...]
1 Like

Your date needs to be parsed as a date to use the formatDate() function. The way you have it is a string value. Use the parseDate() function and specify the format of the date that is a string value. Then you use the formatDate() to change it to your desired format.

I also tried it like this here:

{{formatDate(parseDate(“2024-08-20 12:00”; “YYYY-MM-DD HH:mm”); “YYYY-MM-DD”)}}

but this outputs again:

1 Like

Try placing it into another parseDate() function like this:
{{parseDate(formatDate(parseDate(“2024-08-20 12:00”; “YYYY-MM-DD HH:mm”); “YYYY-MM-DD”))}}
image

When you format a date it changes into a text value. For that particular field it is looking for a date value. But the input value is correctly displaying a date so should work…

this gives me exactly the same result as in my previous post. same like in my previously posted two screenshots. :confused: I mean this must be a bug then???

1 Like

Perhaps try adding the format YYYY-MM-DD to the outer parseDate() function

Hi @dan634

Try the following:

{{formatDate(parseDate("2024-08-20 12:00"; "YYYY-MM-DD HH:mm"); "YYYY-MM-DD")}}


Output:
image
Best regards,

Msquare Automation
Gold Partner of Make
@Msquare_Automation