Calculate number of days without weekends

I am creating a leave aplication app where user will apply leave by selecting the days that they would like to be on leave. However, users will be able to select full day or half day leave.

Hence, I would like to be able to calculate the period of leave application applied excluding weekends

For example,
18 January to 29 January will be 10 days

is this possible?

Yes it’s possible

How can i do it?