Number of days between dates.

Hello All,

I have a two dates called Baseline Date and Clearing Date. I have Number of Days varibale. I need to exclude staurday and sunday from this number.

For Ex: Baseline :11/14/18
Clearing Date:10/15/18
Number of days=30.

It should display 22.

=DaysBetween([Baseline Date];[Clearing Date])

Thanks
SH


SH3230 (BOB member since 2010-10-25)

IF you are using SQL Server, and IF you can add objects to the universe, this might help.


charlie :us: (BOB member since 2002-08-20)

If not, there are two options depending on how accurate you need to be.

If it doesn’t have to be 100% and the periods are relatively long, just multiply the difference by 5/7.

If you need accuracy, that means a very long if statement asking whether the period starts on a Monday, ends on a Monday; starts on a Tuesday ends on a Monday . . . . . .

It’s doable, as long as you don’t need to allow for holidays.


mikeil (BOB member since 2015-02-18)

Can you please provide the code, i need to exclude the weekends as well as holidays also.

Thanks
SH


SH3230 (BOB member since 2010-10-25)

It’s tricky. There is an explanation of one method here:

and here:


mikeil (BOB member since 2015-02-18)