6 Replies Latest reply on Jul 7, 2017 5:35 PM by gofmp15

# Calculating coming Monday or Wednesday or Saturday

lets say today is Tuesday. How can I calculate the coming date which is Monday or Wednesday or Saturday (whichever comes first)

For example if today's date is: 4th July (Tuesday) then the date I want is: 5th July (Wednesday).

If it's  8th July (Saturday) Then the date I want is 10th July (Monday )

• ###### 1. Re: Calculating coming Monday or Wednesday or Saturday

Let ( [ D = YourDateFieldorVariableHere ;

Sun = D - DayOfWeek ( D ) + 1 ;

Mon = Sun + 1 ;

Wed = Sun + 3 ;

Sat = Sun + 6 ] ;

Case ( Mon >= D ; Mon ;

Wed >= D ; Wed ;

Sat )

) ;

• ###### 2. Re: Calculating coming Monday or Wednesday or Saturday

let ( weekday = DayOfWeek ( date );

date +

case(weekday=0; // sunday

weekday=1; monday

...)

• ###### 3. Re: Calculating coming Monday or Wednesday or Saturday

I would write a recursive custom function that examines the Get(CurrentDate) for DayOfWeek()

or this

• ###### 4. Re: Calculating coming Monday or Wednesday or Saturday

As Coherenkris points out FileMaker has exactly what you need. All you need to do is convert a 1 to Sunday, 2 to Monday. The results are numeric.

patricia

• ###### 5. Re: Calculating coming Monday or Wednesday or Saturday

I think you may wish to finish this out for the OP.

Day is Sunday, +1 // the following Monday

Day is Monday, + 2 // the following Wednesday

Day is Tuesday, + 1 // the following Wednesday

Day is Wednesday, + 3 // the following Saturday

Day is Thursday, + 2 // the following Saturday

Day is Friday, +1 // the following Saturday

Day is Saturday, + 2 // the following Monday

Beverly

• ###### 6. Re: Calculating coming Monday or Wednesday or Saturday

What you want to is advance the day if it is a certain day of the week (what about holidays)?

In English:

Advance date:  date + Number of days

If nbr = 1 //sunday

nbr = 2  //monday

end if