# Number of days between 2 dates excluding weekends

Hi All

After some help/guidance on a app i am building for work.

The app basically is a holiday planner, in which an employee can select a start and end date and book the time off. (We are paper based at the moment and due to covid we need to move to an online solution)

I have set up an employee’s working week, so for example the employee works Monday to Friday 09:00 - 17:30. (This is saved in my database as a list of numeric days for the user eg 0,1,2,3,6)

So the next logical step would be for me to calculate the number of days used in a given period. I have read up and down the forum and got close a few times but not managed to get the right solution.

Link below is the closest, but in my case i have 2 date pickers (One for the start and one for the end date, i need to keep it this way) - so this is not working for me.

Anyone got any ideas of how to work this out, open to any ideas as this is the key element to the app.

Thanks for reading

Are you referencing the number of days an employee has worked in a given period? Or are you simply wanting to calculate the number of days between the start and end date?

If you want to calculate the number of days from start to end that is simple enough. However, if you want to calculate that value and exclude weekends it would get trickier.

Check this post

This post may be of help as well

There is a way to get a list of dates using a plugin, but I can’t find the thread at the moment but do some digging and you should find it.

Thanks boston85719

It is the latter option i am afraid, i need to calculate number of days taking out certain work days (might not be a weekend if the employee’s shift is say Friday, Saturday, Sunday & Monday - i would want to omit Tues, Wed & Thursdays from the date range)

The thread i linked does work if it is just one date picker with all the dates selected, but as i am using 2 i can’t get the list side of things.

Thanks for the links, the top one i have already used to build a yearly view of dates taken. This section i am after is just the base data to plug into it.

Found a solution: well it does what i need it to do - a big thanks to boston85719 for prompting me to the second post above.

(Not sure if it is the best solution, will let an expert have some input on that)

Right to get this working i had to install the plugin 1T list of dates, i also used the airdate/time picker, but it does work with the normal time picker.

I have 2 time pickers - Pick A and Pick B (Start and End dates)

Set up the list of dates so it starts at the date picker start date and number of days is end date - start date

Once done you can then use a simple text box to show if it working (Thanks to Profile - romanmg - Bubble Forum)

Taken me a while to work this out, so if this saves anyone anytime then it is worth the update

5 Likes

This topic was automatically closed after 70 days. New replies are no longer allowed.