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

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

Need function to find difference between two dates

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

Hi all

I need a function written in vb to find the exact month difference between two dates.

For example

    Start Date : 01/01/2010

    End Date   : 15/02/2010

 then the difference value should be like this 1.5  i.e i need the difference in decimal value.

View Complete Post

More Related Resource Links

How to create a "search function" to find files and folders using C++ windows forms?

As mentioned above, how can I make a windows forms application that searches for files and folders specified by the user and display results in a ListBox? Thanks in advance another question: How can I make a textbox transparent? I would be really grateful if anybody told me what books are good to learn windows forms using C++? thanks again

find number of sundays between two dates using sql

can i find total number of sundays between two dates using sql? or total number of days between two days except sundays

Find missing dates


Hi I   find days missing between dates for expamle. 10 may 2010 , 11 may 2010, 13 may 2010 , with this code

                List<DateTime> dateTimes = new List<DateTime>();

                foreach (String sDate in s)
                    dateTimes.Add(DateTime.ParseExact(sDate.ToString(), format, CultureInfo.InvariantCulture));

                //Check for missing dates thats will indicate an Overlap Booking

                for (int i = 1; i < dateTimes.Count; i++)
                    if ((dateTimes[i] - dateTimes[i - 1]).TotalDays != 1)
                        DateTime start = DateTime.Parse(txtStart.Text);
                        DateTime end = DateTime.Parse(lblEnd.Text);

                        ConstructTable(start, end);
                        //btnBook1.Visible = true;
                        lblError.Text = "Bookings May Not Overlap";

then this shows an error  lblError.Text = "Bookings May Not Overlap";

But now say i have got a textbox with these dates in it , wich i have

19 September 2010,20 September 2010,21 September 2010,22 September 2010,23 September 2010,19 September 2010,<

Difference between procedure and function ?

What is the difference between procedure and function

Get Difference between two dates as Hours, Minutes



 I am using the below query to get difference beiween two dates in hours and minutes.Minutes part look ok but the hours is incorrect.

 select datediff(minute,LastDate,getdate()) as "Minutes", datediff(hour,LastDate,getdate()) as "Hours"from emp.

 Note: Using SQL Server 2005


How do I find which queries use a given function



I have a Table-valued Function and a large number of views that potentially use it, I would like to produce a list of views in which the function is called as I need to edit each to make changes.

I am using SQL Server 2005, I have used the right-click to look at dependencies and this brings up a short list of SPs in which the function is used. I know there are views that call the function.

I hope this makes sense.

How to calculate difference between two dates in years


hi all, 

i need to know if, given a birth date, a person has more than x years. Thats mean, the client must entry a date in a textbox and i need to know if the persona has more than 18 years. 

Thx in advance

SSIS Function for find the Occurance of a character


Please help me to find the solution for the below requirement.

Input data: "AAAA,BBBB,CC" or "A,B,CCC"

I need to check whether the record is having any comma(,) or not. I need to check this this in a "conditional split transformation".

Please let me know which function will help me.

Many Thanks,


Cannot find either Column "dbo" or the user-defined function or aggregate "dbo.GetCandiateID", or th



Good morning to everybody. I am not understanding why I am getting the following error (also mentioned in the subject line).

I have written the following function in SQL Server 2005:

    declare @candidate_id int
    SELECT @candidate_id = max(c.candidate_id) from dbo.candidates c
    if(@candidate_id is null)
        set @candidate_id = 1001
        set @candidate_id = @candidate_id + 1
    return @candidate_id

The function compiled properly. I have used the above function like below in the query:

select dbo.GetCandidateID()

I am getting the following error:

Cannot find either column "dbo" or the user-defined function or aggregate "dbo.GetCandidateID", or the name is ambiguous

Whats difference between $find and document.getElementbyID???


Whats difference between $find and document.getElementbyID???

I'm using both and I see no difference.

Program to find first non repetable character in a string without using any buitin function?


Program to find first non repetable character in a string without using any buitin function?

EndScene function is called with several Direct3D devices.How to find out which one is a WPF window,



I am working on a screen grabbing application, which has a feature of grabbing a particular window. To make my application working with WPF applications with a good speed, I have chosen a "Direct3D hooking" approach for grabbing image of a WPF window, which means that I install hooks for some Direct3D calls, specifically, EndScene function. This works because WPF uses Direct3D for rendering windows contents.

However I ran into the following issue:
EndScene is called with several Direct3D devices, not a single one. I have looked into contents of each device's back buffer and found out that in addition to main window rendering, there are separate devices which are used for rendering of menus and tooltips.
However EndScene is called just with a pointer to a D3D device which is used for rendering and no information about whether a main window is rendered or a menu/tooltip. Also no information is available about position of menu/tooltip relative to main window coordinates (so that with that information I could compose a single image rendering images of window and menus/tooltips together).

So my question is: given Direct3D device which is used for rendering a window, how to identify a window (WPF window) by ob

Get difference between 2 dates in minutes


I have 2 datetime columns:

Date1 = 10/1/2010 11:00:00 PM

Date2 = 10/2/2010 1:00:00 AM

I want to subtract Date 2 from Date1 and return the number of minutes difference.  Something like:

Date1 - Date2 = 120

How can I do this?




How to find the Eastern Time after Daylight Saving Time difference (GMT - 4) or (GMT - 5)


Hi All,

I am using SQL Server 2005.

I have a requirement to find the Eastern Time,

Which is (GMT - 4) during Daylight Saving Time(DST)

and (GMT - 5) during non DST.


Can anyone help to develop a logic without hard coding any date and time values, to find the Eastern Time(EST)?


Thanks in Advance...



Error "Could not find server 'System' in sys.servers" with non-context connection in CLR function


When trying to open a non-context connection in a CLR scalar valued function I am receiving the Exception:

Could not find server 'System' in sys.servers. Verify that the correct server name was specified. If necessary, execute the stored procedure sp_addlinkedserver to add the server to sys.servers

I encounter this problem on two different SQL Server 2005 servers. The error seems strange to me since I am not using linked servers.

Here is an extract from my function:



class LimitSystemFunctions
  public static<

Need a function to find and format initials in a string


the following rules need to be applied to initials:

- if a two letter initial is required, type them in capitals with no space or stops between them. (eg. BB Construction)

-If a name requires an initials follow it with a space with no stop (eg.  A Sander Davids)

- initials should always be in caps

I need a function that can do the above, any help will be appreciated.


Find week number in xpath from two dates in SharePoint 2010



I am trying to determine the week of the year from two dates. The first date will be the first day and month of that year (e.g. 01/01/2005) and the second will be the date of a document(05/05/2005). We tried to accomplish this same task within SharePoint, not using the SP Designer, however, we could not because we could not utilize the name column. Anyhow below is what I got so far. I search for a date function to perform subtraction but could not find any. Thank in advance.


ddwrt:FormatDate(substring($thisNode/@FileLeafRef.Name,1,10),1041,1) -ddwrt:FormatDate(concat(substring($thisNode/@FileLeafRef.Name,1,4),'-01-01'),1041,1)

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