.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Logic to calculate business hours

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net

Hi All,

I have tried searching all over the web for this logic. Got many but half of them did not match what i was looking for and half were malfunctioning.

I want to calculate business working hours between 2 datetime, where in I should be able to set the working hours as well as weekends and holidays should not be calculated.


Please help me guys... It will be a great help... 

View Complete Post

More Related Resource Links

calculate business day between two dates

Hi Guys   I need the count of business days between two  dates Date1, Date2 i need the count only business day (exclude sartuday&sunday) If date1 is null or nothing i need to pass 0 If date2 is null or nothing i need to pass 0   help on this

MOSS 2007 Calculate Due Date including working hours and working days

Hi, I've searched many forums for an answer to my problem but with very limited success. Basically, I've created a Sharepoint list where I would like to track a resolution of incidents versus SLA timings. I have a column with a receiving date, which is a date when the request was submitted and another column with priority code where I have 3 possible values: low (5 working days to close the request), medium (3 days) and high (1 day). What I would like to do is to automatically calculate due date for solving the incident based on the receiving date and the priority code. The thing is that now it is getting more complicated since I need to exclude saturdays and sundays from calculation, as well as national holidays. Then I would like to take into account working hours (from 8am to 4pm), for example if an incident with medium priority was submitted on Friday 5pm, then it would have its due date set to Wednesday 4pm (the request was sent after working hours so we have 3 full working days to complete it) Not sure if it is feasible to achieve using formulas, maybe some other way?

Best way to implement business logic

I am trying to migrate our current SQL CRM to Sharepoint Server 2010. At first I tried using BCS but I couldn't figure out how to implement a many-to-many lookup relationship. So now I am trying to use SSIS to move the SQL data into the lists in Sharepoint. Right now, I have accounts and contacts as lists. Now I am trying to implement the business logic where an account can have multiple contacts and a contact can have multiple accounts and when a user associates a contact with an account (or vice versa), that account should automatically be associated back with the contact. It seems this cannot be accomplished with a declarative work flow like in SPD. Am I correct in thinking that the best way to implement this is with 2 sequential workflows in Visual Studio?  Also, is a workflow always preferrable to an event receiver? Thanks!

How to calculate the hours?



How would you calculate the hours?

05:00 15:00 = 10 hours
07:00 12:00 = 5 hours

12:15 to 14:30 = 2 hours 15 minutes.


VB code behind the Business Logic Layer ???


Hello. I was hoping for some general help and comments.

I went through a lot of the ASP.Net Web Forms Tutorials.

I also went though the whole "ASP.Net in 24 Hours" book by Scott Mictchell. I followed everything that went on in that book and built the final project successfully. I also used the tutorials here to better understand the whole Membership Provider/User tables setup that was going on in the book.

Next, I thought I would learn more about accessing data for ASP.Net since that is what most application do.

I went through the first Data Tutorial here. I seemed to understand what was going on just fine.

The second Data Tutorial seemed to just show a lot of VB code to build the Business Logic Layer. There was not much explanation about how to do it yourself.

I think I can keep going in the tutorials here. I downloaded the code from the second tutorial and went through it.I am guessing that the code in the second tutorial was given just to proceed with the overall project that is being built throughout the tutorial sequence.

I just wish I understood what is going on in those long lists of VB code. I can see some of what is going on. I don't know VB very well at all. So, what is the next step?

I have started working through a VB book. Will learning VB help me understand the code in that tu

How to calculate working hours betwwen two dates?


Working days - Mon-Fri and Working hours - 9 Am to 5 Pm

Date1                                       Date2                                                Working Hours

Thur, 14-Oct-10 11.30 Am          Thur, 14-Oct-10 5.00 Am                     5.30

Fri,  15-Oct-10 11.30 Am            Mon, 18-Oct-10 5.00 Am                      13.30

Mon,  18-Oct-10 11.30 Am          Mon, 18-Oct-10 6.00 Am                      5.30


Thanks & Regards, PSWA

Separate class library for controllers,models,repositories,business logic


Alright after scratching my mind for a while.. I still cant figure out how to go ahead with my architecture: http://forums.asp.net/p/1618613/4149672.aspx#4149672

nor i can find a decent link / info on it...So, iam goin to give this one more try.

How to calculate total work hours between dates?

I am in the process of creating a calendar.  This calendar is to track leave hours for employees.  For example if a person takes leave for 2.5 days then the formula would calculate 8hrs per day and 4 hours for half a day = 20hrs.  I have part of the formula I believe "=TEXT([End Time]-[Start Time],"h")".  The problem is that it does not count multiple days and just not working right. Any advice would help.

Web Part remote update and centrally located business logic


Hi everyone,

We have a web application with a search engine that our customers want to integrate into their Sharepoint environment with automatic login. I'm not familiar with Sharepoint myself but have a question around the practicality of it. I realise that we have two options:

1. Display my web app in an IFRAME. The benefit of this approach is that my Sharepoint users will automatically benefit from any update made to the web app. The downside is that they cannot download any search results directly to their Sharepoint folders.

2. Create a full Web Part to "rebuild" the full user interface of my search engine for Sharepoint. The Web Part will access my web app through back-end APIs. The benefit of this approach is that users can download results directly into their Sharepoint folders. However a big downside is that anytime there's an update to the web app, I have to implement it separately on the Web Part and redeploy it. I'm discouraged by this because that means I have to update the Web Part on every customer's Sharepoint instance.


My question is. Is there option #3 that's a midway between option #1 and #2? Is there a way I can create a thin Web Part accessing "proxy" code that is centrally updateable without having to touch every Web Part deployment? Hopefully this option allows me to get the ben

How to use business logic in MVC



I've got a C# MVC 2 application using EF 4. My DAL project gets data from the Model, translates them into POCO's and returns ViewModels to the BLL which is called from the controllers.

I've set up validation attributes on the POCO classes and that works for "Required" fields etc. I would like to add business logic such as "From" has to be before the "To" date. Can this be done on the POCO classes so it is automatically validated client-side in the view?

Also, I would like to add some functionality to the BLL layer such as checking if a resource is already booked between the From and To dates to avoid double bookings. This should fire before the ViewModel is saved. I tried a Try/Catch statement in the controller so that I can throw an error in the BLL, but I don't understand how to return this error to the view with an appropriate error message added.



[Business Logic Handler debugging] - The assembly is not loaded by inetinfo.exe process


Hi there,

Here is my story - my merge replication topology consists of one publisher (sql server 2008), a distributor (same server as publisher) and a subscriber (sql server 3.5 CE). I use web synchronization for my merger replication. Publisher, Distributor, Subscriber and IIS run all on the same (development) machine. I use MSSMS to synchronize the subscriber.

I've created a custom resolver (Business Logic Handler) that should perform some data modification that has been inserted at the subscriber, before it is merged into the publisher. It should but it doesn't so I need to debug it to see what's going on. I've followed steps form here http://msdn.microsoft.com/en-us/library/ms365150.aspx on how to debug a business logic handler on a Web server using Web synchronization and I'm stuck at step 7. MY PROBLEM IS when I attache to inetinfo.exe process from VS2008, I don't see my assembly to be loaded neither in Output nor in Modules window and the break points say that they will not be hit because the symbols were not loaded.

I configured web synchronization almost exactly as it says here http://msdn.microsoft.com/en-us/library/ms151810.aspx , the only difference is that I didn't configured and

INFOPATH: how can I calculate hours between 2 date fields in a list form


I am trying to calculate the number of hours between 2 date/time fields in a list form.

If I do this on a list view level with a calculated column, the column is not available for column summaries. Therefor I intend to use a regular number column and calculate the hours in an InfoPath form. Obviously the formula for calculated fields in list columns will not work in InfoPath.

Addition: I tried DateField1-DateField2, but the result is NaN...




Need advice on how to use WF4 to manage my business logic in my ASP.NET MVC3 app


I want to use WF4 in my ASP.NET MVC3 app and now trying to get the hang of how WF4 should interact with the MVC app.

Say, I want WF 4 to help me with the registration process. I want new users to go through the following steps:

  1. Register
  2. Activate account
  3. Fill out personal profile
  4. Fill out professional profile

Clearly, all the registration logic and UI elements will be in the MVC3 app. I assume WF4 will be where I will check to see if the user has completed these steps.

What I'm not clear about how will WF4 tell my MVC app where to send the user? Here's what I'm thinking, please let me know if this approach makes sense

New registrations will initiate long running workflows and bookmarks will get saved in SQL Server. I will have four UI views in the MVC app with their corresponding logic in their respective controllers. How will I WF4 tell MVC what to do i.e. what URL to send the user to and what parameters to pass?

Thanks, Sam

How to best organize multiple WebProjects that use similar business logic


We have the following setup

Current Solution:

  • Business Logic (Class Library)

  • Data Layer (Class Library containing EF,Web Services wrappers etc)

  • WebProject1

BUT we now require a new Web Project which would be almost identical to WebProject1 except for the fact that it would alter properties and input variables to functions/voids inside the Business Logic class to provide a different set of data for another completely different user. Think of Facebook as WebProject1 and Myspace as WebProject2. Same concept, same business layer almost but different products altogether.

Future Soltion

  • Business Logic (Class Library)

  • Data Layer (Class Library containing EF,Web Services wrappers etc)

  • WebProject1

  • WebProject2 (similar to WebProject1 but different authentication, different UI, different pages etc)

  • WebProject3 (possible)

Without completely destroying the Business Logic (as the class would now have to allow for 2 paths per set of input variables) how can we structure this to aviod doubling up on any code?

The delima is:

Should we maintain two Business Logic class libraries? Should we add preffixe

function to calculate number of business days in a month for a given date


hi ,

Is there any function to calculate number of business days in a month for a particular date.  my input would be just a single date



Access business logic through a webservice


This should be fairly straightforward, but there seems to be nothing on how to do this.  So far  I've just created wrapper WebMethods and that accessed most of my methods fine, except for the one that returns an object that inherits icollection.  The error returned says to create a default accessor for the class (I don't want to touch the existing business classes, as they are being used elsewhere.)  But, I'm also sure theres many more problems along the way.  So, is there complete documentation to do this?  Or a proper tool to generate a webservice layer?


Business Modelling and Web Applications and extending UML

UML can be used to model a business, prior to automating it with computers. The same basic UML syntax is used, however, a number of new symbols are added, in order to make the diagrams more relevant to the business process world. A commonly-used set of these symbols is available in current versions of Rational Rose.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend