Converting String to Number and Returning as Array

I need some Javascript to transform a string into a number and return it as an array for use in the rest of the workflow. I’m not very Javascript proficient and have tried this formula but it doesn’t return anything:

const schedule_date = parseInt("sch_date")
const date = Object.keys(schedule_date)
return date

I saw this post, but am unsure about how to relate this to my modules - can this be put directly into an expression or should I use a Function node?

Hello @pford, so you want to transform a date into a unix timestamp?

Do not fully understand this? what is sch_date? is it a field coming from another node?

const schedule_date = parseInt("sch_date")

Thanks as always Ricardo! Yes sorry I should have explained more. I have a date coming in from a webhook as ISO, then a Date & Time node converting it to a Unix timestamp, but because the incoming data is a string, the output of the Date & Time module is also a string (“sch_date” is just the key for the value returned by the Date & Time module. The Clickup node I’m using requires the date be sent as Unix and as a number instead of a string. So I need the Unix string converted to a number and placed within an array so n8n can process the rest of the workflow.

Ahh got it. You can do that with an expression directly in the ClickUp Node. Should look like {{parseInt($node["Function"].json["sch_date"])}}. Of course, you have to change Function for the name of the node you are referencing.

Let me know if that helps.

1 Like

As usual, yes it works perfect thank you! It was much more simple that I anticipated.

Glad that it worked. As always, let us know if you have any other questions.