difference between 2 dates

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

    #1

    difference between 2 dates

    I would like to know how I can calculate the diference in time between 2
    dates. I would input a date (before the current date) and the code would
    calulate how many: weeks, days, hours, minutes and secondes there is between
    the given date and the current date.

    thanx in advance!

    Lovens


  • Richard L Rosenheim

    #2
    Re: difference between 2 dates

    This should answer your question:

    http://msdn.microsoft.com/library/de...sDateTopic.asp

    Richard Rosenheim


    "weche" <fw1803@videotr on.ca> wrote in message
    news:Xw%Md.4949 1$rd7.990289@we ber.videotron.n et...[color=blue]
    > I would like to know how I can calculate the diference in time between 2
    > dates. I would input a date (before the current date) and the code would
    > calulate how many: weeks, days, hours, minutes and secondes there is[/color]
    between[color=blue]
    > the given date and the current date.
    >
    > thanx in advance!
    >
    > Lovens
    >
    >[/color]


    Comment

    • Cor Ligthert

      #3
      Re: difference between 2 dates

      Lovens,

      For your question is the timespan structure.

      http://msdn.microsoft.com/library/de...classtopic.asp

      And before you try to do difficult things, look at the properties and
      methods from that.

      As well can you look at the date and time methods in the
      Microsoft.Visua lBasic namespace about dates, they can be very helpfull and
      although a lot of the functions in this namespace are in another way in the
      standard framework, are here some which are not.

      http://msdn.microsoft.com/library/de...rykeywords.asp

      I hope this helps,

      Cor


      Comment

      • Herfried K. Wagner [MVP]

        #4
        Re: difference between 2 dates

        "weche" <fw1803@videotr on.ca> schrieb:[color=blue]
        >I would like to know how I can calculate the diference in time between 2
        > dates. I would input a date (before the current date) and the code would
        > calulate how many: weeks, days, hours, minutes and secondes there is
        > between
        > the given date and the current date.[/color]

        \\\
        Dim d1 As Date = Now
        Dim d2 As Date = #4/22/1989#
        MsgBox(CStr(Mat h.Round(d1.Subt ract(d2).TotalS econds, 0)))
        MsgBox(CStr(Dat eDiff(DateInter val.Second, d2, d1)))
        ///

        'DateTime.Subtr act' will return a 'TimeSpan'. This structure provides
        properties like 'Days', 'Minutes', 'Seconds', ...

        --
        M S Herfried K. Wagner
        M V P <URL:http://dotnet.mvps.org/>
        V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

        Comment

        Working...