Calculate Days

Hi Community,

I have one Arrival Date and on Departure Date. Now I will calculate the stay Days.
What is the best way to calculate this. :slight_smile:

Hey.

@Manuel.Techflow.ai did a great video on this.

That should answer your question perfectly.

3 Likes

Thank you for the share @IainM!

If you have any questions about it @Bjoern, feel free to ask follow up questions and we’re all happy to help.

1 Like

Fantastic. It works fine :slight_smile:

2 Likes

Awesome :muscle: Glad you got it to work.

1 Like

Hello, I hope it is okay to post here instead of making a new thread.

I am following the formula to calculate days between two dates in the video (and it is also in the documentation for the date functions), but it is always returning NaN. These are both date fields in my database, and I have also tried the other permutations it sends over (e.g., the date/time timestamp, ISO date, etc.). Same result

image

I have also tried it without any rounding function, etc.; it just doesn’t like my date fields, which appear in my bundles like this:

image

I also notice that when I go back and view the scenario, the field names from my database records have been replaced by the raw field number, which is not typical behavior for the scenario builder.

image

Any idea what I could be missing? The only thing that works is simply subtracting the two UNIX timestamps, but I’m unsure how to convert that into days, if it’s even possible

2 Likes

Try to wrap both dates in a parseDate() function first to transform them into the standard ISO format of dates.
Then the calculation should work correctly.

For transforming timestamps, you can also use the parseDate() function.
At the end, you can use formatDate() to put it into a nicely formatted date the way you need it. This will turn it into a string format.

1 Like