function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Guru Vemuru 1Guru Vemuru 1 

How to send email alert only on week day not in weekends?

Hi all,

I have a requirement to sent email alert to lead owner  and conditions are like
  1. Alert will go to lead owner after 2 hours from lead created time
  2. Lead owner will get mail only Week days and not in week ends
Guru Vemuru 1Guru Vemuru 1
I created Time base work flow there i given (TimeValue(Created Date) =2 Hrs). It working

How can i find out day is Sat and Sun.
 Leads which are coming on sat ansd sun. we have to send mail alert on Monday morning 11am.
how to do it
Salesforce DeveloperSalesforce Developer
No any straight forward solution, create a custom field and set the field with the date on which email should be sent.
Guru Vemuru 1Guru Vemuru 1
I found the created day is it sun, mon..... and according to that by giving condition I can able send mail.

Now the problem is the leads which are created in sun and sat. I have to notify on Monday morning 11 AM.
How can I do it
Tunde OdutolaTunde Odutola
Hi Guru,
I modified a formula that i found on the iner net and have used before but I have tested for your case.

MOD( date - DATE( 1900, 1, 7 ), 7 ),
6, (Created Date) + 59/24 days),
7, (Created Date) + 35/24 days),
(TimeValue(Created Date) =2 Hrs)
The formula finds the day of the week of the date field value. If the date is 6, Saturday you add 2 days and 11 hours, if it is 7, Sunday add an extra day and 11 hours, you may need to take account of your time zone relative to GMT and adjust the hours accordingly.
Jon Raney 2Jon Raney 2
For Posterity I believe Salesforce Developer's comment is correct now that WEEKDAY() is a legit function is SF since 2018.
  • Use the weekday(datefield) function and set that as a formula and use the formula field as criteria rather than as time trigger. 
  • Let Salesforce do the GMT dates natively based on the normal time trigger
  • Presuming the Date field is Date/Time field, wrap that with DATEVALUE formula
  • Replicate the email alert into 2 Workflow rule/alerts with the 2 different criteria date=, date <>
    • Alert 1 criteria for Lead Create Date formula field: WEEKDAY(DATEVALUE(CreatedDate ))= 1)) || (DATEVALUE(CreatedDate ))= 7)) && (whatever other criteria you have)
    • Alert 2 criteria for Lead Create Date formula field: : Same as above, swapping <> 

Bhavya Rumpal 9Bhavya Rumpal 9
The Weekday funcion is good. But if you need the Date time value eg in my use case, I have to send email exactly 4 hours after the lead is created but not on weekends. So, I tweeked the formula that @Tunde has provided and it worked as needed:

Created a new field 'Weekday with Time' and used the formula below:
MOD( DATEVALUE(CreatedDate)- DATE( 1900, 1, 7 ), 7 ),
0, ((CreatedDate) + 1),
6, ((CreatedDate) + 2),

Here 0 is Sunday and 6 is Saturday. So we are basically adding 1 day when its Sunday and 2 days when it is Saturday. So suppose your lead gets created on 9/3/2023 9:46AM (Sunday), the Weekday with Time will be the same time Monday 9/4/2023 9:46AM.

Also if you want to send it in the business hours, this package ( ( can be installed. You can use an Action element to call the Apex method  and pass in a date/time method to compare against business hours.