Saving date and time in automation creation

Hi Guys,

I tried to save a date with time in create action but the time was not saved.

i have this json from webhook:

{
  "Employee": "John Doe",
  "Leave_Type": "Training",
  "Pay_Request": "Unpaid",
  "Start_Date": "2024-02-19 08:00",
  "End_Date": "2024-02-20 21:00",
  "Details": "this is a test leave"
}

and in my script:

const p_startdate =  payload["Start_Date"];
const startdate = moment(p_startdate, "YYYY-MM-DD hh:mm").toDate();
const p_enddate = payload["End_Date"];
const enddate = moment(p_enddate, "YYYY-MM-DD hh:mm").toDate();

when i pass the startdate and enddate to a create block, the time was not included only the date.
then i tried to separate the time and getting error.
How can i save the date time?

Please help :slight_smile:

Hi @comfreakph

I hate dates and times! :wink:

I have just tried this and it seemed to work with my pretend data:



I am not sure what I am doing differently other than using date_fns rather than moment.

However:

  1. make date/time object
  2. This could be key - Add new date/time object via β€˜Calculation’ to your date/time field

Hopefully, it helps

1 Like

@Jason thank you so much, will try this solution