Difference between dates

Discussion in 'ASP.NET' started by vidyadeb, May 8, 2012.

  1. vidyadeb

    vidyadeb New Member

    Joined:
    May 8, 2012
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Please advice my two get diffrence of two dates .Please also check attach. Please suggest this also or can send total different way doing it .
     

    Attached Files:

  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    You are expecting too much by attaching your issue. You want someone to download solve and then give back to you where as you have not taken the pain to explain the issue inline.
     
  3. bzforum

    bzforum New Member

    Joined:
    May 20, 2012
    Messages:
    25
    Likes Received:
    7
    Trophy Points:
    0
    Occupation:
    CEO & Founder
    Location:
    Mumbai , India
    Home Page:
    http://bzforum.in/index.php
    I took the pain to open the doc and see what the OP needed...

    He needs to get a Difference between 2 dates...a Start Date and the End Date but he wants to count it as months..

    that means if the user has selected 01 June 2012 to 01 Aug 2012 the result should be 2 Months..

    And here is the solution for it in VB.NET..

    PHP:
            Dim startDate As DateTime DateTime.Now
            Dim endDate 
    As DateTime DateTime.Now.AddMonths(20)

            
    Dim totmonths As Integer DateDiff(DateInterval.MonthstartDateendDate)

            
    Response.Write(totmonths)
    and C#

    For this you have to Reference to System.Data.Linq
    PHP:
            DateTime startDt DateTime.Now;
            
    DateTime endDt DateTime.Now.AddMonths(20);
            
    int tot System.Data.Linq.SqlClient.SqlMethods.DateDiffMonth(startDtendDt);
            
    Response.Write(tot);    
    I hope this has solved your querry...and next time be nice to post the description of the problem in the post..
     
    shabbir likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice