Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Difference between two dates while excluding the weekends

Featured Replies

Hi people

I'm having a bit of trouble here, and I've tried trawling through previous posts but haven't really found anything helpful.

Problem: I'm trying to put together a formula that will allow me to calculate the turnaround time it's students assessment to be marked.

I have two dates, 'date_received' and 'date_marked', and obviously the turnaround time would be the difference between these two dates.

What I would like to do however, is exclude the weekends in this calculation, so if an assessment was received on the Friday, but marked on the Monday, then the turnaround time would be "1", and not "3".

Anyone have any ideas on how to do this? I'm sure it's relatively easy, but I'm having trouble getting my head around this.

thanks in advance

Cory

There are a couple of custom functions on Brian Dunning's web site that will do this: one of them is

http://www.briandunning.com/cf/179

You'll need FMP Advanced to add custom functions to a file.

  • Author

Hi Vaughn,

thanks for that. What can I do if I don't have Advanced? Any ideas?

What can I do if I don't have Advanced? Any ideas?

If you don't have Advanced, then type in or copy/paste the calculation directly each time you need to apply it in a calculated field or script step instead of creating a handy centralized function.

Custom functions can add greatly to the convenience of developing a solution, but they aren't strictly necessary.

Custom functions can add greatly to the convenience of developing a solution, but they aren't strictly necessary.

I am afraid you are very much mistaken about that. If a custom function is recursive (i.e. it calls itself, as does the function that Vaughan suggested), you cannot use the same formula in a calculation field.

You don't need a custom function for this. Assuming both your start date and end date never occur on a weekend, you could use:

Let ( [

s = StartDate - DayOfWeek ( StartDate ) ;

e = EndDate - DayOfWeek ( EndDate ) ;

w = Div ( e - s ; 7 )

] ;

EndDate - StartDate - 2 * w

)

Note that this doesn't take into account any holidays that might fall in the given range.

Edited by Guest
Forgot to warn about holidays.

This topic has come up in the past, just do a search for your Keywords [color:blue]+WorkDay +Calculations (include the pluses as shown), and that should get you going.

If you need to be concerned about Holidays, there are a few posts that show that as well.

Lee

  • Author

Hi, thanks for that! Seems to work a charm!

Holidays aren't too big an issue for me, just the weekends so this will be fine - thanks!

Don't suppose you could walk me through the code do you? Best if I can learn what you've done, as opposed to just copying and pasting...

Again, thanks everyone for your assistance

/Cory

Roughly, it computes the number of weeks between the dates, and subtracts 2 days for each from the elapsed days.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.