date difference

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • vince

    #1

    date difference

    Hi,

    How do i find difference between two dates?

    thanks
    Vince
  • Jan Tielens

    #2
    Re: date difference

    You can use the Add and Substract methods of the DateTime class.
    Dim a As DateTime = DateTime.Now
    Dim b As DateTime = DateTime.Now

    MsgBox(a.Subtra ct(b).ToString)


    --
    Greetz

    Jan Tielens
    _______________ _______________ __
    Read my weblog: http://weblogs.asp.net/jan



    "vince" <anonymous@disc ussions.microso ft.com> wrote in message
    news:079401c3bb 06$48f305b0$a30 1280a@phx.gbl.. .[color=blue]
    > Hi,
    >
    > How do i find difference between two dates?
    >
    > thanks
    > Vince[/color]


    Comment

    • Mattias Sjögren

      #3
      Re: date difference

      [color=blue]
      >How do i find difference between two dates?[/color]

      date1 - date2

      or

      date1.Subtract( date2 )



      Mattias

      --
      Mattias Sjögren [MVP] mattias @ mvps.org
      http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
      Please reply only to the newsgroup.

      Comment

      • vince

        #4
        Re: date difference

        thanks , it works.

        [color=blue]
        >-----Original Message-----
        >You can use the Add and Substract methods of the DateTime[/color]
        class.[color=blue]
        >Dim a As DateTime = DateTime.Now
        >Dim b As DateTime = DateTime.Now
        >
        >MsgBox(a.Subtr act(b).ToString )
        >
        >
        >--
        >Greetz
        >
        >Jan Tielens
        >______________ _______________ ___
        >Read my weblog: http://weblogs.asp.net/jan
        >
        >
        >
        >"vince" <anonymous@disc ussions.microso ft.com> wrote in[/color]
        message[color=blue]
        >news:079401c3b b06$48f305b0$a3 01280a@phx.gbl. ..[color=green]
        >> Hi,
        >>
        >> How do i find difference between two dates?
        >>
        >> thanks
        >> Vince[/color]
        >
        >
        >.
        >[/color]

        Comment

        • Morten Wennevik

          #5
          Re: date difference

          DateTime d1 = new DateTime(2000, 7, 13);
          DateTime d2 = new DateTime(2003, 12, 5);
          TimeSpan s = d2 - d1;
          int numberofdays = s.TotalDays;

          A timespan contains a number of different ways to show the difference.

          --
          Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

          Comment

          Working...