cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
wordsmither
Level: Powered On

Default Date = today plus 3 days, excluding weekends.

I've tried making sense of the documentation and other posts, but I just can't get this to work. On new, I want the "due date" to default to today's date plus 3 days. I've got that working fine with this code: If( SharePointForm1.Mode=FormMode.New, Now()+3, Parent.Default ) But if that falls on a weekend, I would like it to default to the next Monday. Any way to do this?
1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Default Date = today plus 3 days, excluding weekends.

Hi @wordsmither

You could use something like this in your formula. 

If(
    Weekday(Today() + 3) = 7,
    Today() + 4,
    Today() + 3 || Weekday(Today() + 3) = 6,
    Today() + 5,
    Today() + 3
)

This says that if Today()+3 is Sunday, then add 4 days to Today Or if Today()+3 is a Saturday, Add 5 days to Today.  You should be able to work this formula into your mode formula.

3 REPLIES 3
Super User
Super User

Re: Default Date = today plus 3 days, excluding weekends.

Hi @wordsmither

You could use something like this in your formula. 

If(
    Weekday(Today() + 3) = 7,
    Today() + 4,
    Today() + 3 || Weekday(Today() + 3) = 6,
    Today() + 5,
    Today() + 3
)

This says that if Today()+3 is Sunday, then add 4 days to Today Or if Today()+3 is a Saturday, Add 5 days to Today.  You should be able to work this formula into your mode formula.

Community Support Team
Community Support Team

Re: Default Date = today plus 3 days, excluding weekends.

Hi @wordsmither,

Based on the needs that you mentioned, I think the Weekday function could achieve your needs.

I assume that you use Sunday as the first day of one week, I have made a test on my side, please take a try with the following formula:

If(
SharePointForm1.Mode = FormMode.New,
If(
Weekday(Now()+3) = 7,
Now() + 5,
Weekday(Now()+3) = 1,
Now() + 4,
Now() + 3
),
Parent.Default
)

If you use the Monday as the first day of one week, please take a try with the following formula:

If(
SharePointForm1.Mode = FormMode.New,
If(
Weekday(Now() + 3, StartOfWeek.Monday) = 6,
Now() + 5,
Weekday(Now() + 3, StartOfWeek.Monday) = 7,
Now() + 4,
Now() + 3
),
Parent.Default
)

More details about the Weekday function, please check the following article:

Weekday function

 

Best regards,

Kris

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
wordsmither
Level: Powered On

Re: Default Date = today plus 3 days, excluding weekends.

Perfection! Thank you!