Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 976573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:46:05+00:00 2026-05-16T03:46:05+00:00

The following code has been created from a different post, but I now have

  • 0

The following code has been created from a different post, but I now have a separate issue. What this code does is basically takes the 2 dates and subtracts weekends from it to get the overall time elapsed in minutes from start to end time excluding weekends. I am now trying to say since there is 11 hours in a work day for me I want to only count 11 hours per day. The results I get are as follows(I added the column names just so you know what they are):

@AllMins  @MinDays
2173         1.50902777777778

Since there are 660 minutes in a work day or 780 minutes not working in a work day I need to subtract this from the overall time. So, 1 day would be 2173-780, but I also need to get the .50902777777778 minutes in the day. Any suggestions?

DECLARE @StartDate DATETIME
DECLARE @EndDate DATETIME
SET @StartDate = '2010-08-02 00:00:00.000'
SET @EndDate = '2010-08-03 12:13:12.123'

--How many minutes are between order start and end time including non working time
DECLARE @AllMins INT 
--Declares how many minutes are in a day and makes it float to get remainder minutes when divided
DECLARE @MinsInDay FLOAT 
SET @MinsInDay = 1440

--Finds how many minutes are between start and end time excluding weekends and assignes to variable 
SET @AllMins = ((DATEDIFF(mi, @StartDate, @EndDate)) 
  -(((DATEDIFF(wk, @StartDate, @EndDate) * 2) * 24) * 60)  
  -(((CASE WHEN DATENAME(dw, @StartDate) = 'Sunday' THEN 1 ELSE 0 END) * 24) * 60)
  -(((CASE WHEN DATENAME(dw, @EndDate) = 'Saturday' THEN 1 ELSE 0 END) * 24) * 60)) 

--Calculates how many days have elapsed in the minutes that the order has taken
DECLARE @MinDays FLOAT
SET @MinDays = (@AllMins/@MinsInDay)

SELECT
@AllMins
,@MinDays
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T03:46:06+00:00Added an answer on May 16, 2026 at 3:46 am

    Are you looking for

    @AllMins - (integer portion of (@MinDays) * 780) - (fractional portion of (@MinDays) * 360)
    

    so that you are subtracting the portion of the 780 minutes from the fractional part?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code that has @item.ID from razor: <a href=# id=deleteitem(@item.ID)>Delete</a> When
I have tried the following code but has no effect: Imports system.Runtime.InteropServices <DllImport(UxTheme.DLL, BestFitMapping:=False,
I've been struggling with the following issue for hours now. I tried this with
Perhaps this question has been asked before in a different way, but I haven’t
I am generating a simple form with php. The following code has been reduced
SOLVED. Code has been edited to reflect solution. Given the following GridView : <asp:GridView
I've been working this issue for a while now and I am open to
I have tried multiple variations of the following code, but I still get the
Referencing the code below, I have a list of Error objects that has been
I know similar questions have been asked but they all have different answers and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.