Click here to Skip to main content
12,625,694 members (37,669 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VB
hi friends,
how to count between two date ?
please help me
Posted 25-Dec-12 21:20pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

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)));
            Console.ReadKey();
        }
    }
}
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

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...
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.161205.3 | Last Updated 26 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100