Skip to main content
New tool CRON Expression Builder — preview next run times before you schedule Apex. Open the builder →
A visual representation of Salesforce Flow Builder showcasing date validation logic for specific days of the month
Flow

Screen Flow validation for 1st Monday and Last Friday

I had to block users from picking the first Monday or the last Friday of the month in a flow. Instead of reaching for Apex, I used one Boolean formula resource to handle the Screen Flow validation.

The short answer

This guide shows how to stop users selecting the first Monday or last Friday of any month in a Salesforce Screen Flow, using a declarative Boolean formula resource. The formula compares the selected date against the calculated boundary days and enforces the check directly on the Screen Flow Date input component, with no custom Apex.

Key takeaways Validate Screen Flow date inputs with a Boolean formula resource rather than custom Apex or hardcoded record dates. Work out recurring blackout dates with the standard date functions: DATE(), YEAR(), MONTH(), MOD(), and WEEKDAY(). Reference the Boolean formula in the Validate Input section of the Date component, and write a clear error message for when the formula returns false. Test the date validation logic in a sandbox across months that start on different weekdays, since WEEKDAY() behaves differently by locale and time zones matter too.

Why Screen Flow validation matters for date logic

I was working on a project recently where the business had some very specific rules about when orders could be submitted. We needed a solid Screen Flow validation to stop users from picking the first Monday or the last Friday of any given month. It sounds niche, but these scheduling "blackout dates" come up more often than you'd think in payroll or logistics apps.

You could handle this with a bunch of Get Records elements or even a custom Apex action. That's overkill. Most of the time a simple formula resource does it, which keeps your flow clean and leaves you with no extra code to maintain.

A mockup of the Salesforce Flow Builder showing a new formula resource being created.

Creating the formula resource that the Date component will validate against.

What you'll need to get started

Before we jump into the math, make sure your Screen element is ready. You'll need a Date input component (let's call it SelectedDate). You'll also need a Formula resource that returns a Boolean value. That formula is what tells Salesforce whether the date is "good" or "bad" against your business rules.

If you're still getting comfortable with the basics, some best practices for Salesforce Flow will help you keep the logic organized before things get complex.

Building the Screen Flow validation formula

We need to find the first day of the month, work out when that first Monday lands, then do something similar for the last Friday. It's a head-scratcher if you haven't done date math in Salesforce before, but the logic is pretty consistent.

I've seen teams try to solve this by hardcoding dates in a custom object. Don't do that. A formula is much more reliable because it handles every month and year automatically without you ever having to touch it again.

Copy the logic below into a Formula resource in your Flow. Just make sure the return type is set to Boolean so the Screen Flow validation knows how to read it.

/* Logic to block 1st Monday and Last Friday */
/* Replace {!SelectedDate} with your actual screen component name */

/* 1. Calculate the First Monday */
(
  DATE(YEAR({!SelectedDate}), MONTH({!SelectedDate}), 1) + 
  MOD(9 - WEEKDAY(DATE(YEAR({!SelectedDate}), MONTH({!SelectedDate}), 1)), 7)
) != {!SelectedDate}

&&

/* 2. Calculate the Last Friday */
(
  IF(MONTH({!SelectedDate}) = 12,
    DATE(YEAR({!SelectedDate}) + 1, 1, 1),
    DATE(YEAR({!SelectedDate}), MONTH({!SelectedDate}) + 1, 1)
  ) - 1 - 
  MOD(WEEKDAY(IF(MONTH({!SelectedDate}) = 12,
    DATE(YEAR({!SelectedDate}) + 1, 1, 1),
    DATE(YEAR({!SelectedDate}), MONTH({!SelectedDate}) + 1, 1)
  ) - 1) - 6 + 7, 7)
) != {!SelectedDate}

The formula returns "True" if the selected date is NOT the first Monday and NOT the last Friday. For Screen Flow validation, "True" means the input is valid and the user can move to the next screen. If it's "False," the error message pops up.

Applying the logic to your screen component

Once your formula is ready, go back to your Screen element. Click your Date input and look for the "Validate Input" section in the right-hand sidebar. In the Formula field, reference the Boolean formula you just created. Don't forget a helpful error message, something like "Sorry, we don't accept submissions on the first Monday or last Friday of the month."

One thing that trips people up is the difference between doing this in Flow versus Apex. A formula is great here, but there are times when code is better. If you're curious about where that line sits, I wrote a bit about Apex vs Flow that might clear it up.

Testing and common pitfalls

Don't build this and walk away. You've got to test it across different months. Check a month where the 1st is a Monday, and a month where the 1st is a Tuesday. The WEEKDAY() function in Salesforce can be a little finicky depending on your locale settings, so always double-check your work in a Sandbox first.

Keep an eye on time zones too. If your users are spread across the globe, a date might look like a Monday for one person but still be Sunday for another. For simple date fields this usually isn't a problem, but it's worth keeping in the back of your mind for more complex Screen Flow validation scenarios.

Key takeaways

  • Use a Boolean formula resource to keep your Screen Flow validation logic declarative.
  • The WEEKDAY() function is what you lean on to find specific days of the week.
  • Always provide a clear error message so users know exactly why their date was rejected.
  • Test across multiple months, or you won't know whether your math holds up.

Keeping this logic inside the flow makes life easier for the next admin who inherits it. It's clean, it's fast, and there's no extra code to maintain. If you run into weird errors with the date math, reach out or drop a comment. I've probably hit those same walls before.

Frequently asked questions

How do you validate a date input in Salesforce Screen Flow?

Add a Date input component to your Screen element and configure the Validate Input section in the sidebar. Reference a Boolean formula resource that evaluates to true when the input is valid, then write the error message the user sees when it evaluates to false.

How do you calculate the first Monday of a month in a Salesforce formula?

Take the first day of the month with DATE(YEAR(date), MONTH(date), 1), then add MOD(9 - WEEKDAY(DATE(YEAR(date), MONTH(date), 1)), 7) to shift forward to the first Monday.

How do you calculate the last Friday of a month in a Salesforce formula?

Get the last day of the current month by subtracting one day from the first day of the next month, then subtract MOD(WEEKDAY(LastDay) - 6 + 7, 7) to land on the final Friday.

Newsletter

One email every Tuesday

New guides, tool updates, and the release-note changes that break things.

No spam. Unsubscribe in one click.

Comments

Loading comments...

Leave a Comment