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
ssurferssurfer 

How to calculate Bank days in salesforce?

Hi,
 
I've got a small problem. In a team edition of salesforce, i've got a standard field under opportunities called close date. I was to create a custom formula field that gives me the date 5 bank days from the close date. This means skipping saturday and sunday. I've not been able to solve this, does anyone have any ideas how i can do it?
 
Best regards,
johan
MKPartners.comMKPartners.com
The Excel function needed to perform this is called WEEKDAY.  It determines the day of the week of a specific date.  Unfortunately, SFDC doesn't have this function available yet.

I recommend logging a feature request.

Sorry.


eric_falskeneric_falsken
what about something like datediff to get # of days from a known sunday and if that number mod 6 or mod 7 is 0 then you have a sat/sunday.
eliotstock2eliotstock2

He's right you know. This seems to work:

 

 

private static Date knownMonday = Date.newInstance(2009, 1, 5); public static Boolean isSaturday(Date d) { // daysBetween() is always positive Integer diff = knownMonday.daysBetween(d); return (Math.mod(diff, 7) == 2); } public static Boolean isSunday(Date d) { Integer diff = knownMonday.daysBetween(d); return (Math.mod(diff, 7) == 1); } public static Boolean isMonday(Date d) { Integer diff = knownMonday.daysBetween(d); return (Math.mod(diff, 7) == 0); }

 

 

 

eliotstock2eliotstock2

Sorry, I mean this:

 

 

private static Date knownSaturday = Date.newInstance(2009, 1, 10); private static Date knownSunday = Date.newInstance(2009, 1, 11); public static Boolean isSaturday(Date d) { // daysBetween() is always positive Integer diff = knownSaturday.daysBetween(d); return (Math.mod(diff, 7) == 0); } public static Boolean isSunday(Date d) { Integer diff = knownSunday.daysBetween(d); return (Math.mod(diff, 7) == 0); }