### Browse by categories

- All
- Additional Products
- Collaboration
- Configuration & Data Management
- CPQ and Billing
- Customer Service & Support
- Desktop Integration
- Einstein Analytics
- Email Marketing
- Journey Management
- Mobile
- Mobile Messaging
- MuleSoft Composer for Salesforce
- Packaging, Uploading & Installing Apps
- Reports & Dashboards
- Sales & Marketing
- Security
- Social Marketing
- Trailhead Challenges

# Formula to extract day of the week from a date field

Thanks!

Sami EllongTry this:

CASE( MOD(

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

## All Answers

Sami EllongTry this:

CASE( MOD(

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

Aniqa MoinuddinWorks like a charm! Thanks a lot :D Shikha JaiswalThis is simple and sweet -- DateTime dt = system.today();

String day = dt.format('EEEE'); //day would show expected outcome.

Jamie SmithI needed to use @Sammi's example with CreatedDate - a DateTime datatype so altered with DATEVALUE(CreatedDate) and figured I'd share for the next person.

Thanks @Sammi for the method.

Hamayoun KhanThanks again @Sammi, I needed to run a workflow only on Friday, and this allowed me to figure out how to do that. Meta HirschlThanks so much @sami - worked perfectly. Next problem -- new formula field wasn't showing up to use for report. that's when I found the "Fields Available for Reports". One thing leds to another. thanks to all! Mike O'NeillThank you @sami Minhaj_Developer ArifinThank you @Sami and @Jamie! Rahul GautamWorks great for me, Thanks a lot @Sammi Travis GibbonsNew to Salesforce. When I attempt this, the syntax doesn't check out. Thoughts? Thanks! Fraidy StraussThank you @Sami and @Jamie! Exactly what I was looking for! Kevin Carl DavidUPDATE: As of Spring 2018, there's a built-in function for this: WEEKDAY(). It returns an integer where 1 is Sunday, 2 is Monday, 3 is Tuesday, etc. - EZ :-) Annaleece Best@Kevin Carl David - how do we utilise this new WEEKDAY function?

I've tried the above formula and keep getting syntax errors.

Jim Stoltzfus@Annaleece you might have to combine it with DATEVALUE if the field is a datetime field, like WEEKDAY(DATEVALUE(CreatedDate)) = 1 Gerri Wheeler@Kevin Carl David -thank you for the heads up on the new formula. I used it to render Text in a field like this:

CASE(WEEKDAY(DATEVALUE(CreatedDate)),

1,"Sunday",

2,"Monday",

3,"Tuesday",

4,"Wednesday",

5,"Thursday",

6,"Friday",

7,"Saturday",

"")

Krishnan MishraIf you are doing this in Apex, you can try the below:

Date tdy = Date.today();

System.debug(tdy); // 28-01-2019

Datetime dt = (DateTime)tdy;

String dayOfWeek = dt.format('EEEE');

System.debug(dayOfWeek); // Monday

Jimmy Zambrano@Kevin Carl David and @Gerri Wheeler and everyone -Thank you your help! This worked for me.

To provide a little background: I needed to create a formula field named "Day of Monitoring" that would render the day of the week from a field named "Date of Monitoring".

Just to walk through the steps of what I did to make this work for me:

1- Created a "Formula" field

2- Selected "Text" for "Formula Return Type"

3- Copied and pasted Gerri Wheeler's formula and customized to fit my needs as follows:

CASE(WEEKDAY(Date_of_Monitoring__c),

1,"Sunday",

2,"Monday",

3,"Tuesday",

4,"Wednesday",

5,"Thursday",

6,"Friday",

7,"Saturday",

"")

Thanks again!

Lynnae TaylorHi everyone - thank you for all of this great information!

I am trying to get the weekday of the Opportunity Close Date, but I keep getting a syntax error. Any tips?

Daymon BoswellHi Lynnae,

I just tried this using the standard close date field on the Opportunity and didn't recieve any errors - make sure that your formula type is text when setting up the field. Here is the formula I used:

CASE( MOD( CloseDate - DATE(1900, 1, 7), 7), 0, "Sunday", 1, "Monday", 2, "Tuesday", 3,

"Wednesday", 4, "Thursday", 5, "Friday", 6, "Saturday","Error")

Sagar GoswamiWhen i change the date to 19/1/2020 it doesn't show any results in the below formula:

CASE(

MOD(DATEVALUE( CreatedDate ) - DATE(2020, 19, 1) ,7),

0, "D",

1, "L",

2, "M",

3, "X",

4, "J",

5, "V",

6, "S",

"None"

)

WHY????

Rebekah CampbellI've seen several formulas for excluding weekends, but I'm struggling to create a report which excludes weekends in calculating the number of days since a task was modified. Can anyone help? Thank you in advance! Joan PrestonThanks for the great formula! The report I created groups by rows to get the weekday record counts. The weekdays are listed in order from Friday to Wednesday. Is there a way to re-order the report to start on Monday? Adam Meliski@joan, I ran into the same problem. Days seem to be sorted alphabetically. I renamed the days (1 Sunday, 2 Monday, etc...) in the formula to enact a workaround, but I still wonder if there's a better way. April BortschellerIs there any way to get the same results from a Date/Time field?