DateTime as a value in a key/value pair

For some reason my dropdown doesn’t like using a datetime value as the value portion of a label/value pair. Any reason why this wouldn’t work? sailDate is a datetime field.

function dropdownOptions ( data ){
return data . map ( item => {
return {
label : item . sailDate . toLocaleDateString ()+ " " + item . period ,
value : item . sailDate
}

}) 

}

btw…it works fine when I convert to string via: value: item.sailDate.toLocaleDateString. But I’m trying to store this in the form’s data table as a datetime so I can use it elsewhere.

Hi Mike,

A Dropdown can’t store a datetime.
What you can do is,
Use a hook on the database it gets inserted to.
Use the before insert hook → change the string back to a date value .
Here is the Velo API Reference page for the beforeInsert hook.

https://www.wix.com/velo/reference/wix-data/hooks/beforeinsert

Hope this helps.

Kind regards,
Kristof