# How to Convert this formula Into Calculating the date/time difference for only in weekdays(Monday to Friday Only)

I have a formula for to calculating date/time fields difference in hours as followingly,

``````(((DATEVALUE( NOW()) - DATEVALUE(Calculating_Date__c))-1)*24 )
+
(24 - VALUE(MID(RIGHT((TEXT( Calculating_Date__c  + 0.2291)),9),0,2)))
+
VALUE(MID(RIGHT((TEXT(  NOW() + 0.2291)),9),0,2))
``````

Here It's used to calculate the date/time difference in hours form. And here the value of the 0.2291 is the value of getting local time from the GMT time.(my org using time is GMT +5.30)

But I want now is To calculate the date/time difference in hours only for week days.Like If I select the day in the Calculating Date and Now() is 10/8/2016 and 10/15/2016 means it's provide the difference is in like the only in this dates the week days are 5 so the answer is provided to the 120 hours.

Here I also want this answer is also provided to the future days also in same way Like the Calculation Date and NOW() is 10/29/2016 and 10/15/2016 means it's provided the value in the answer is -120 hours(I want the difference in future days are in having negative values).

This 120 hours values are to be getted to the adding the value of remainding hours the calculation Date in 24 hours and the adding the NOW() values in the current hour compulsury.

And also the formula is also providing the appropriate correct result in the middle days also Like the condition of the Calculation Date and NOW() values are in same day and the difference of both two date's are in only 4 or less then 5 days.

Then that formula is calculated the weekdays value even I select the My CalCulating date and NOW() in this two date/time fields are in any one or both also pointing to the weekend days.

If you wanted to calculate days you could do a formula. Quick google search yields:

Calculate the number of days between two dates while excluding weekends or excluding weekdays

https://help.salesforce.com/HTViewSolution?id=000004526

If you are wanting the number of hours you are left with:

Formula

``````ROUND( 8 * (
( 5 * FLOOR( ( DATEVALUE( ***date/time_1*** ) - DATE( 1900, 1, 8) ) / 7) +
MIN(5,
MOD( DATEVALUE( date/time_1 ) - DATE( 1900, 1, 8), 7) +
MIN( 1, 24 / 8 * ( MOD( date/time_1 - DATETIMEVALUE( '1900-01-08 16:00:00' ), 1 ) ) )
)
)
-
( 5 * FLOOR( ( DATEVALUE( date/time_2 ) - DATE( 1900, 1, 8) ) / 7) +
MIN( 5,
MOD( DATEVALUE( date/time_2 ) - DATE( 1996, 1, 1), 7 ) +
MIN( 1, 24 / 8 * ( MOD( date/time_2 - DATETIMEVALUE( '1900-01-08 16:00:00' ), 1) ) )
)
)
),
0 )
``````

https://developer.salesforce.com/docs/atlas.en-us.usefulFormulaFields.meta/usefulFormulaFields/formula_examples_dates.htm

Code