Calculate number of nights between arrival date and departure date

I am working on a booking calendar. I get the prices calculated, which is a surprise on my side :slight_smile:
Now I need to calculate the number of nights between arrival date and departure date. Which would be something like arrival date - departure date - 1.
Can someone get me to get this done please?

SELECT
      `events`.`start` AS `start`,
      `events`.`end` AS `end`,
      (TO_DAYS(`events`.`end`) - TO_DAYS(`events`.`start`)) AS `Nights`
    FROM `events`

Something like that?

Well you can calculate days between dates using the data formatter…

2 Likes

Sorry Teodor, I should quit posting SQL. It’s an old habit. I’m sure Wappler makes it far easier.

There is a days until formatter option, which returns the difference between two dates. Combine it with other calculations like the one you showed:

And you have your calculations done as you need them. Just follow the simple logic you explained already in your first post.

Found it and done it. Working perfect!

2 Likes