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
Craig PhoenixCraig Phoenix 

Show When Record Created On Weekend

I am wanting a checkbox formula to checkmark when the record CreatedDate is either Saturday or Sunday (Weekend).

I have tried searching around however all I am finding is comparing two dates and not counting weekend days which is not what I am needed.

Any help would be appreciated!
Best Answer chosen by Craig Phoenix
CharuDuttCharuDutt
Hii Craig Phoenix
It Can Be Done By Formula Field Type Checkbox.


CASE(
MOD( DATEVALUE( CreatedDate ) - DATE( 1900, 1, 7 ), 7 ),
0, 'true',
1, 'false',
2, 'false',
3, 'false',
4, 'false',
5, 'false',
'true'
) = 'true'

Please  Mark It a Best Answer If It Helps...

All Answers

Foram Rana RForam Rana R
Hi,

Please go through the below code.
 
public String readableDay(Date d) {
Datetime dt = DateTime.newInstance(d.year(), d.month(), d.day());
return dt.format(‘EEEE’); //returns Sunday or Monday or .. 
}

Thanks,
Foram Rana
 
CharuDuttCharuDutt
Hii Craig Phoenix
It Can Be Done By Formula Field Type Checkbox.


CASE(
MOD( DATEVALUE( CreatedDate ) - DATE( 1900, 1, 7 ), 7 ),
0, 'true',
1, 'false',
2, 'false',
3, 'false',
4, 'false',
5, 'false',
'true'
) = 'true'

Please  Mark It a Best Answer If It Helps...
This was selected as the best answer
Craig PhoenixCraig Phoenix
Thanks CharuDutt - That worked perfectly!