13,591,670 members
See more:
hi friends,
how to count between two date ?
Posted 25-Dec-12 20:20pm

## Solution 1

```using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
DateTime dtA = new DateTime(2012, 12, 25);
DateTime dtB = new DateTime(2012, 12, 26);

Console.WriteLine("Day Difference : " + Math.Abs(DateTime.Compare(dtA, dtB)));
}
}
}```

## Solution 2

```Dim i As Integer
Dim Date1 As Date
Dim Date2 As Date
Date1 = CDate("1 Jan 2012")
Date2 = Now.Date
i = DateDiff(DateInterval.Day, Date1, Date2)
Msgbox("Days Difference: " & i)
i = DateDiff(DateInterval.Month, Date1, Date2)
Msgbox("Month Difference: " & i)
' Similarly You can Calculate Difference of Weeks, Years, Hours, Secs, Minutes
' between two Dates...```

Top Experts
Last 24hrsThis month
 OriginalGriff 195 Jochen Arndt 90 Paschga 85 kirthiga S 65 Maciej Los 65
 OriginalGriff 3,730 Jochen Arndt 2,292 ppolymorphe 1,784 Maciej Los 1,681 Thaddeus Jones 1,483