locked
Getting Wrong Value When Calling .Net C# Function From SQL Server Via Query RRS feed

  • Question

  • Hi,

    I desperately need some guidance/help.

    I'm calculating working hours between two dates depending on the workshift (5 day per week, 8 hours per week). For better understanding of the I'm giving following example.

    OpenDate: 18-Jun-2009

    CloseDate: 6-Jan-2010

    Can check the number of days for approximation from this link http://www.timeanddate.com/date/duration.html

    Number of Days for above days will 203, so roughly there will 145 days and for 8 working hours total working hours will 1160 for 203 days which in minutes are 69,600. This is approximate

    Now let me explain what I'm doing and what i'm getting.

    I created Assembly/DLL in C# to do the calculations of working hours, when I tested this in Visual Studio its gives correct results i.e 69,414 minutes, which is correct.

    I registered this DLL on SQL Server 2005 successfully. And when I invoke the C# method from SQL query for a single record it gives correct result same as i was getting in VS i.e 69,414 minutes.

    But when I run this query with many records it gives me different value, for example one record with above mentioned dates gives me 83,334 minutes and its strange i don't know whats wrong and where

    Difference between two values is 232 hours which is huge and above its unreliable value. So this is issue if you need more info please let me know.

    Quick will be highly appreciated.

    Kind Regards.

    Sohail.


    Always ask experienced rather than knowledgeable.
    Wednesday, April 28, 2010 3:28 PM

Answers