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
lopezclopezc 

Is there a way to know which day of the week is today()?

Hi

Is there any way to know if today() is a weekend day or not?

 

I need to create a task 3 days after a lead is been created but I need to exclude the weekends.

I have got a formula that tells me how many days since the lead is been created but I can't use workflows on formulas so I am thinking to use Apex. I need to know which day of the week is today(), and based on that I will create my task. 

 

Any ideas?

Best Answer chosen by Admin (Salesforce Developers) 
Scott.MScott.M

You could use the following in apex to get the day of the week:

 

 

// Three letter abreviation example (Fri) String weekday = System.now().format('E'); // Full name exmaple (Friday) String weekday = System.now().format('EEEE');

 

 

 

 

All Answers

JimRaeJimRae

Here is an example from the help that you might find useful:

 

CASE( MOD(TODAY() - DATE(1900, 1, 7), 7), 0, "Sunday", 1, "Monday", 2, "Tuesday", 3, "Wednesday", 4, "Thursday", 5, "Friday", 6, "Saturday", "Error")

 If you test for the mod function equal to 1,2,3,4,5 it should do what you are looking for.

 

 

Scott.MScott.M

You could use the following in apex to get the day of the week:

 

 

// Three letter abreviation example (Fri) String weekday = System.now().format('E'); // Full name exmaple (Friday) String weekday = System.now().format('EEEE');

 

 

 

 

This was selected as the best answer