Date field needs to be converted

Question:
I use this code to update a collection field with dates but whatever I do it always show a yellow row with an exclamation mark telling me that it needs to be converted to date so please help me with this extremely difficult task. No dataset connected because this is about mapped dates so I can´t choose a specific date field. The code makes the date get into the correct members field cell:

let today = new Date($w(“#engdate”).value); const formattedDate = today.toLocaleDateString(“en-US”, { day: “numeric”, month: “short”, year: “numeric”, }); member[rentalStartField] = today; console.log(“Updated rental start date:”, formattedDate); await wixData.update(“Members”, { …member, …updateData });

Here I show it in another way:

$w(“#engBuy”).onClick(async () => {
let today = new Date($w(“#engdate”).value);
const adjustedDate = today.toLocaleDateString(“en-US”, {
})
member[rentalStartField] = adjustedDate;
console.log(“Updated rental start date:”, adjustedDate);

    await wixData.update("Members", { ...member, ...updateData });

Product:
[Wix Editor]

What are you trying to achieve:
[To update the date fields with a correct format value.]

It sounds like you are using the Date field without the “include Time field” selected. This means you need to convert this to an ISO string, and then cut the time part out of the string. So something like today.toISOString().substring(0, 10)

Here’s a thread asking a very similar question that might help.

1 Like

Thank you very much Emmy but I find it very frustrating that such important information is almost actively hidden by Wix support. I have tried in many different ways and for many days until you finaly told me this solution.

No problem! Your frustration is totally understandable, I’ll pass this feedback along.

1 Like

By the way, how can I combine today.toISOString().substring(0, 10) with a specific format?

Hmm I’m not sure what you mean, could you clarify the format you’re trying to combine with?