Skip 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.

Weekends/Bank Holidays Calc

Featured Replies

I'd like to change a field colour with conditional formatting if possible by using a calc on Date Fields that will flag weekends (Sat/Sun) and Bank Holidays as Colour Red etc.

Is this possible?

Thanks

Well this does it, but something easier might do it for the weekday??:

GetAsBoolean(Filter(DayOfWeek ( Self );"17"))

Similar could be done with FilterValues for the Int( of the date, for bank holidays, but when it comes to easter and such will I suggest you ask Comment, who is an expert on date-issues ... whether or not it goes with this as well should go unsaid:

http://www.ovalbooks.com/bluff/Relationships.html

--sd

  • Author

Hi Soren,

How are you.

See Thread - http://fmforums.com/forum/showtopic.php?tid/192750/

This is really what i am looking for. Do you know the answer to what i asked in the thread link above by any chance.

Thanks,

Sully

You could also try:

Mod ( self - 1 ; 7 ) > 4

But for holidays you will most likely need a list of them.

Please try keeping to one thread per question.

  • Author

Sorry Comment, I will keep to the other thread

Please note that conditional formatting has a switch'ish flow, so there is no need to compile two criteria in one single calc', and especially when two different colours are required.

--sd

Do note that the other thread is about MODIFYING a date, so that a weekend/holiday date is shifted forward to a work date - not about formatting.

But for holidays you will most likely need a list of them

Moveable feasts, shouldn't be plummeting in a Y2K shortcut should it : ??

--sd

  • Author

Sorry guys, i was going to flag the weekend dates etc. in colour so users could then see them immediately so they would know to change them to working dates.

Then i came across Comment's NextWorkday function which would suit better if i can get working.

Well why??? as Todd Geis says:

Sometimes I think FileMaker is too flexible. There are too many easy ways to do things that will absolutely cause you myriads of grief later. I have tried several times to develop my own frameworks, but they always left me feeling like it was too much work

....snipped boldly from: http://www.geistinteractive.com/node/16

--sd

  • Author

Hi Soren,

Is this right for my Calc to turn the Field Red if it is a Sat/Sunday

My second field adds 2 days from the first field so would the calc be the following?

Field1 + 172800 + Mod ( Self - 1 ; 7 ) > 4

using a calc on Date Fields that will flag weekends (Sat/Sun)

If 2 days are 172800, then your field must be a Timestamp, not Date. So perhaps:

Mod ( GetAsDate ( Self ) - 1 ; 7 ) > 4

  • Author

Hi Comment,

But where do i put this code. Do i make a calc field or can i right click on the field for conditional formatting and put it there?

Yes, the field is an SQL timestamp field but the Calc is a date field.

Sorry, i'm lost :

Is there something not simpler in Conditional Formatting where field = Saturday and Sunday (Fill Red)

If 2 days are 172800, then your field must be a Timestamp, not Date. So perhaps:

Mod ( GetAsDate ( Self ) - 1 ; 7 ) > 4

Edited by Guest

It's supposed to go into Conditional Formatting as a formula. But if your calculation field is set to return a Date result, then the formula Field1 + 172800 doesn't make sense. It's not easy to help you...

  • Author

Ok Comment. Thanks for your help.

Would you have a demo file with the previous Let Function perhaps so i can study it perhaps?

  • Author

Hi Comment,

It's working. I tried it again for the hell of it and it worked. You are a legend!

Just for reference. The following worked

Mod ( GetAsDate ( Self ) - 1 ; 7 ) > 4

Thanks a mill

Hi comment,

You never cease to amaze me with your abilities, and knowledge.

You could also try:

Mod ( self - 1 ; 7 ) > 4

But for holidays you will most likely need a list of them.

Can you explain to me what is taking place with the Date here.

TIA

Kia

I could try - if I understood what your question is.

Never mind, I got it.

: ....Let's hear your explanation then!

--sd

sure, what part didn't you understand?

"Never mind" or "I got It"

LOL

Kia

I could be mistaken here, but it gives the impression that you accept spoon-fed knowledge without questioning?

Just that it have happened before:

http://fmforums.com/forum/showpost.php?post/245665/

--sd

I could be mistaken here, but it gives the impression that you accept spoon-fed knowledge without questioning?

Are you implying that I can't think for myself?

I have a suggestion, skip my questions if you can't say anything nice.

Kia

Kiele

It seems like all Soren wanted was for you to explain how you fixed the problem so that other persons who might have the same problen or a similar problen can use your explaination.

I didn't fix a problem, I had a question on how the Mod Calculation worked in this case. Soren is way smarter than I when it comes to calculations, so any insight that I have would have, wouldn't be for his needs. However, I don't mind sharing how the light was turned on, with you.

I used a Date field with the calendar

and

Three calculations fields, to step the Mod Calculation.

Mod ( DateField ; 7 )

Mod ( DateField -1 ; 7 )

Mod ( DateField -1 ; 7 ) > 4

Then by changing the date, I could see the results for the different parts.

HTH

Kia

Alright here it goes, every date correspond to an integer, where the first of january in year 0001 is where it all starts with 1 and where today the 20th of february 2008 is corresponding to 733092.

If we look at Mod( is it the remainder after number is divided by a divisor here 7 ... this means that an arbitrary chosen integer will return another integer in this range {0;1;2;3;4;5;6} ... Seven as divisor is of course the number of days in the week and very much to our luck is saturday and sunday adjacent days so Comment have chosen an offset -1 (the day before) to make the Mod( calc return 5 or 6 in weekend dates.

This means equal results could be obtained by this calc:

Mod ( theDate + 1; 7 ) < 2

But what I have put out a "warrant" for, was the first part, namely how dates are stored in filemaker behind the scenes. It's important to know how the typecasts behave, instead of trial and error in the given situation.

It's bad praxis to just accept the state of things, just on simple and randomly chosen studies of thier behaviours. One could by accident pledge allegiance to the emperors new clothes that way!

So I'm not accusing you for not being able to think for your self, but instead incline on consensus on what just might be a hearsay:

http://www.sciencedaily.com/releases/2008/02/080214114517.htm

--sd

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

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.