Trying to get a Date Breakdown

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

    Trying to get a Date Breakdown

    I am trying to get a overall difference on two dates,

    I can get the difference in Years, Months, Weeks, Days, Hours, Minutes,
    Seconds, no problems...

    What I cannot seem to figure out is how to get:

    2 Years, 3 Months, 1 Week, 3 Days, 14 Hours, 21 Minutes, 33 Seconds.

    The hardest part of that, the part I cannot figure out, is the Month
    section... all the others are static, defined length components, but Months
    change, are all different...

    Help! anyone know how you do this? I am stuck...

    Thanks So Much for your Help!

    Atley


  • Lloyd Dupont

    #2
    Re: Trying to get a Date Breakdown

    what about getting the difference incerementally.

    1st you get the difference in Year and substract it
    2nd you get the difference in month and substract it
    3rd .... (etc ...)

    "Atley" <atley_1@hotmai l.com> wrote in message
    news:OIitcQO$DH A.2040@TK2MSFTN GP12.phx.gbl...[color=blue]
    > I am trying to get a overall difference on two dates,
    >
    > I can get the difference in Years, Months, Weeks, Days, Hours, Minutes,
    > Seconds, no problems...
    >
    > What I cannot seem to figure out is how to get:
    >
    > 2 Years, 3 Months, 1 Week, 3 Days, 14 Hours, 21 Minutes, 33 Seconds.
    >
    > The hardest part of that, the part I cannot figure out, is the Month
    > section... all the others are static, defined length components, but[/color]
    Months[color=blue]
    > change, are all different...
    >
    > Help! anyone know how you do this? I am stuck...
    >
    > Thanks So Much for your Help!
    >
    > Atley
    >
    >[/color]


    Comment

    • Atley

      #3
      Re: Trying to get a Date Breakdown

      Yeah, I thought of that, but how do I decide what to delete from the total,
      based on how many months?





      "Lloyd Dupont" <net.galador@ld > wrote in message
      news:eM0imqO$DH A.212@TK2MSFTNG P12.phx.gbl...[color=blue]
      > what about getting the difference incerementally.
      >
      > 1st you get the difference in Year and substract it
      > 2nd you get the difference in month and substract it
      > 3rd .... (etc ...)
      >
      > "Atley" <atley_1@hotmai l.com> wrote in message
      > news:OIitcQO$DH A.2040@TK2MSFTN GP12.phx.gbl...[color=green]
      > > I am trying to get a overall difference on two dates,
      > >
      > > I can get the difference in Years, Months, Weeks, Days, Hours, Minutes,
      > > Seconds, no problems...
      > >
      > > What I cannot seem to figure out is how to get:
      > >
      > > 2 Years, 3 Months, 1 Week, 3 Days, 14 Hours, 21 Minutes, 33 Seconds.
      > >
      > > The hardest part of that, the part I cannot figure out, is the Month
      > > section... all the others are static, defined length components, but[/color]
      > Months[color=green]
      > > change, are all different...
      > >
      > > Help! anyone know how you do this? I am stuck...
      > >
      > > Thanks So Much for your Help!
      > >
      > > Atley
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Lloyd Dupont

        #4
        Re: Trying to get a Date Breakdown

        I don't get you.

        wether month have different lenght or you modify start or end date, the
        result should be the same (I guess)

        like
        2 Feb (2) 2002 - 1st Jan (1) 2001
        = 1Y + (2 Feb 2001 - 1st Jan 2001) OR 1 year + (2 Feb 2002 - 1st Jan 2002)
        = 1Y + 1M + (2 Jan 2001 - 1st Jan 2001) OR 1Y+1M+(2Feb2002-1stFeb2002)
        = 1Y + 1M + 1D OR 1Y + 1M + 1D

        isn't it ?

        "Atley" <atley_1@hotmai l.com> wrote in message
        news:upYZC2O$DH A.3828@TK2MSFTN GP10.phx.gbl...[color=blue]
        > Yeah, I thought of that, but how do I decide what to delete from the[/color]
        total,[color=blue]
        > based on how many months?
        >
        >
        >
        >
        >
        > "Lloyd Dupont" <net.galador@ld > wrote in message
        > news:eM0imqO$DH A.212@TK2MSFTNG P12.phx.gbl...[color=green]
        > > what about getting the difference incerementally.
        > >
        > > 1st you get the difference in Year and substract it
        > > 2nd you get the difference in month and substract it
        > > 3rd .... (etc ...)
        > >
        > > "Atley" <atley_1@hotmai l.com> wrote in message
        > > news:OIitcQO$DH A.2040@TK2MSFTN GP12.phx.gbl...[color=darkred]
        > > > I am trying to get a overall difference on two dates,
        > > >
        > > > I can get the difference in Years, Months, Weeks, Days, Hours,[/color][/color][/color]
        Minutes,[color=blue][color=green][color=darkred]
        > > > Seconds, no problems...
        > > >
        > > > What I cannot seem to figure out is how to get:
        > > >
        > > > 2 Years, 3 Months, 1 Week, 3 Days, 14 Hours, 21 Minutes, 33 Seconds.
        > > >
        > > > The hardest part of that, the part I cannot figure out, is the Month
        > > > section... all the others are static, defined length components, but[/color]
        > > Months[color=darkred]
        > > > change, are all different...
        > > >
        > > > Help! anyone know how you do this? I am stuck...
        > > >
        > > > Thanks So Much for your Help!
        > > >
        > > > Atley
        > > >
        > > >[/color]
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • Atley

          #5
          Re: Trying to get a Date Breakdown

          Yea, but how would you do that in code, that will work for any dates put in?
          What I am saying is I can't find the constructs or methods that will do this
          effectively.




          "Lloyd Dupont" <net.galador@ld > wrote in message
          news:%23dfTeTP$ DHA.4060@TK2MSF TNGP10.phx.gbl. ..[color=blue]
          > I don't get you.
          >
          > wether month have different lenght or you modify start or end date, the
          > result should be the same (I guess)
          >
          > like
          > 2 Feb (2) 2002 - 1st Jan (1) 2001
          > = 1Y + (2 Feb 2001 - 1st Jan 2001) OR 1 year + (2 Feb 2002 - 1st Jan 2002)
          > = 1Y + 1M + (2 Jan 2001 - 1st Jan 2001) OR 1Y+1M+(2Feb2002-1stFeb2002)
          > = 1Y + 1M + 1D OR 1Y + 1M + 1D
          >
          > isn't it ?
          >
          > "Atley" <atley_1@hotmai l.com> wrote in message
          > news:upYZC2O$DH A.3828@TK2MSFTN GP10.phx.gbl...[color=green]
          > > Yeah, I thought of that, but how do I decide what to delete from the[/color]
          > total,[color=green]
          > > based on how many months?
          > >
          > >
          > >
          > >
          > >
          > > "Lloyd Dupont" <net.galador@ld > wrote in message
          > > news:eM0imqO$DH A.212@TK2MSFTNG P12.phx.gbl...[color=darkred]
          > > > what about getting the difference incerementally.
          > > >
          > > > 1st you get the difference in Year and substract it
          > > > 2nd you get the difference in month and substract it
          > > > 3rd .... (etc ...)
          > > >
          > > > "Atley" <atley_1@hotmai l.com> wrote in message
          > > > news:OIitcQO$DH A.2040@TK2MSFTN GP12.phx.gbl...
          > > > > I am trying to get a overall difference on two dates,
          > > > >
          > > > > I can get the difference in Years, Months, Weeks, Days, Hours,[/color][/color]
          > Minutes,[color=green][color=darkred]
          > > > > Seconds, no problems...
          > > > >
          > > > > What I cannot seem to figure out is how to get:
          > > > >
          > > > > 2 Years, 3 Months, 1 Week, 3 Days, 14 Hours, 21 Minutes, 33 Seconds.
          > > > >
          > > > > The hardest part of that, the part I cannot figure out, is the Month
          > > > > section... all the others are static, defined length components, but
          > > > Months
          > > > > change, are all different...
          > > > >
          > > > > Help! anyone know how you do this? I am stuck...
          > > > >
          > > > > Thanks So Much for your Help!
          > > > >
          > > > > Atley
          > > > >
          > > > >
          > > >
          > > >[/color]
          > >
          > >[/color]
          >
          >[/color]


          Comment

          • Steven Licciardi

            #6
            Re: Trying to get a Date Breakdown

            I'm not sure I understand exactly what the problem is, but isn't it just
            something as simple as:

            Dim d1 As New Date(2006, 10, 20)
            Dim d2 As New Date(2003, 1, 9)
            Dim yDiff As Integer = d1.Year - d2.Year
            Dim mDiff As Integer = d1.Month - d2.Month
            Dim dDiff As Integer = d1.Day - d2.Day

            Or are you asking for something more complicated?

            Steven

            "Atley" <atley_1@hotmai l.com> wrote in message
            news:%238wEnsP$ DHA.3536@TK2MSF TNGP10.phx.gbl. ..[color=blue]
            > Yea, but how would you do that in code, that will work for any dates put[/color]
            in?[color=blue]
            > What I am saying is I can't find the constructs or methods that will do[/color]
            this[color=blue]
            > effectively.
            >
            >
            >
            >
            > "Lloyd Dupont" <net.galador@ld > wrote in message
            > news:%23dfTeTP$ DHA.4060@TK2MSF TNGP10.phx.gbl. ..[color=green]
            > > I don't get you.
            > >
            > > wether month have different lenght or you modify start or end date, the
            > > result should be the same (I guess)
            > >
            > > like
            > > 2 Feb (2) 2002 - 1st Jan (1) 2001
            > > = 1Y + (2 Feb 2001 - 1st Jan 2001) OR 1 year + (2 Feb 2002 - 1st Jan[/color][/color]
            2002)[color=blue][color=green]
            > > = 1Y + 1M + (2 Jan 2001 - 1st Jan 2001) OR 1Y+1M+(2Feb2002-1stFeb2002)
            > > = 1Y + 1M + 1D OR 1Y + 1M + 1D
            > >
            > > isn't it ?
            > >
            > > "Atley" <atley_1@hotmai l.com> wrote in message
            > > news:upYZC2O$DH A.3828@TK2MSFTN GP10.phx.gbl...[color=darkred]
            > > > Yeah, I thought of that, but how do I decide what to delete from the[/color]
            > > total,[color=darkred]
            > > > based on how many months?
            > > >
            > > >
            > > >
            > > >
            > > >
            > > > "Lloyd Dupont" <net.galador@ld > wrote in message
            > > > news:eM0imqO$DH A.212@TK2MSFTNG P12.phx.gbl...
            > > > > what about getting the difference incerementally.
            > > > >
            > > > > 1st you get the difference in Year and substract it
            > > > > 2nd you get the difference in month and substract it
            > > > > 3rd .... (etc ...)
            > > > >
            > > > > "Atley" <atley_1@hotmai l.com> wrote in message
            > > > > news:OIitcQO$DH A.2040@TK2MSFTN GP12.phx.gbl...
            > > > > > I am trying to get a overall difference on two dates,
            > > > > >
            > > > > > I can get the difference in Years, Months, Weeks, Days, Hours,[/color]
            > > Minutes,[color=darkred]
            > > > > > Seconds, no problems...
            > > > > >
            > > > > > What I cannot seem to figure out is how to get:
            > > > > >
            > > > > > 2 Years, 3 Months, 1 Week, 3 Days, 14 Hours, 21 Minutes, 33[/color][/color][/color]
            Seconds.[color=blue][color=green][color=darkred]
            > > > > >
            > > > > > The hardest part of that, the part I cannot figure out, is the[/color][/color][/color]
            Month[color=blue][color=green][color=darkred]
            > > > > > section... all the others are static, defined length components,[/color][/color][/color]
            but[color=blue][color=green][color=darkred]
            > > > > Months
            > > > > > change, are all different...
            > > > > >
            > > > > > Help! anyone know how you do this? I am stuck...
            > > > > >
            > > > > > Thanks So Much for your Help!
            > > > > >
            > > > > > Atley
            > > > > >
            > > > > >
            > > > >
            > > > >
            > > >
            > > >[/color]
            > >
            > >[/color]
            >
            >[/color]


            Comment

            • Cor

              #7
              Re: Trying to get a Date Breakdown

              Hi Atley,

              Did you know that Date is the topic of this week on MSDN

              .NET is a developer platform with tools and libraries for building any type of app, including web, mobile, desktop, games, IoT, cloud, and microservices.


              Cor


              Comment

              • Dominique Vandensteen

                #8
                Re: Trying to get a Date Breakdown

                something like this?

                dim date1 as datetime
                dim date2 as datetime

                dim ticks1 as long = date1.ticks
                dim ticks2 as long = date2.ticks

                dim difference as new timespan(math.a bs(ticks1 - ticks2))


                Dominique




                "Atley" <atley_1@hotmai l.com> wrote in message
                news:OIitcQO$DH A.2040@TK2MSFTN GP12.phx.gbl...[color=blue]
                > I am trying to get a overall difference on two dates,
                >
                > I can get the difference in Years, Months, Weeks, Days, Hours, Minutes,
                > Seconds, no problems...
                >
                > What I cannot seem to figure out is how to get:
                >
                > 2 Years, 3 Months, 1 Week, 3 Days, 14 Hours, 21 Minutes, 33 Seconds.
                >
                > The hardest part of that, the part I cannot figure out, is the Month
                > section... all the others are static, defined length components, but[/color]
                Months[color=blue]
                > change, are all different...
                >
                > Help! anyone know how you do this? I am stuck...
                >
                > Thanks So Much for your Help!
                >
                > Atley
                >
                >[/color]


                Comment

                • Atley

                  #9
                  Re: Trying to get a Date Breakdown

                  Thanks, but i can get the DateDiff several different ways, the problem is
                  with the breakdown into how much time is left as a rundown ie 1 year, 2
                  months, 1 week, 3 days, 6 hours, 23 minutes, 41 seconds...



                  "Dominique Vandensteen" <domi.vds_inser t@tralala_tenfo rce.com> wrote in
                  message news:OK5fkhS$DH A.552@TK2MSFTNG P11.phx.gbl...[color=blue]
                  > something like this?
                  >
                  > dim date1 as datetime
                  > dim date2 as datetime
                  >
                  > dim ticks1 as long = date1.ticks
                  > dim ticks2 as long = date2.ticks
                  >
                  > dim difference as new timespan(math.a bs(ticks1 - ticks2))
                  >
                  >
                  > Dominique
                  >
                  >
                  >
                  >
                  > "Atley" <atley_1@hotmai l.com> wrote in message
                  > news:OIitcQO$DH A.2040@TK2MSFTN GP12.phx.gbl...[color=green]
                  > > I am trying to get a overall difference on two dates,
                  > >
                  > > I can get the difference in Years, Months, Weeks, Days, Hours, Minutes,
                  > > Seconds, no problems...
                  > >
                  > > What I cannot seem to figure out is how to get:
                  > >
                  > > 2 Years, 3 Months, 1 Week, 3 Days, 14 Hours, 21 Minutes, 33 Seconds.
                  > >
                  > > The hardest part of that, the part I cannot figure out, is the Month
                  > > section... all the others are static, defined length components, but[/color]
                  > Months[color=green]
                  > > change, are all different...
                  > >
                  > > Help! anyone know how you do this? I am stuck...
                  > >
                  > > Thanks So Much for your Help!
                  > >
                  > > Atley
                  > >
                  > >[/color]
                  >
                  >[/color]


                  Comment

                  • Cor

                    #10
                    Re: Trying to get a Date Breakdown

                    Hi Atley,

                    Did you look at the
                    timespan.ticksp ersecond
                    timespan.ticksp eryear
                    timespan.ticksp erhour
                    etc.

                    I hope this helps,

                    Cor


                    Comment

                    • Dominique Vandensteen

                      #11
                      Re: Trying to get a Date Breakdown

                      aha
                      you can do somthing like this...

                      [color=blue][color=green]
                      > > dim date1 as datetime
                      > > dim date2 as datetime
                      > >
                      > > dim ticks1 as long = date1.ticks
                      > > dim ticks2 as long = date2.ticks
                      > >[/color][/color]
                      Dim dt As New DateTime(math.a bs(ticks1 - ticks2))
                      Dim msg As String = "Differnce is:" & vbCrLf & _
                      "years: " & (dt.Year - 1) & vbCrLf & _
                      "months: " & (dt.Month - 1) & vbCrLf & _
                      "days: " & (dt.Day - 1) & vbCrLf & _
                      "hours: " & dt.Hour & vbCrLf & _
                      "minutes: " & dt.Minute & vbCrLf & _
                      "seconds: " & dt.Second

                      doing -1 for year, month and day:
                      new datetime(ticks as long) -> gives you a date, not a timespan
                      and the date is calculated as the number of ticks since 01-01-0001 00:00:00
                      so doing -1 for day, month and year gives you the remaining time for each
                      datetime part

                      isn't that kewl :-)


                      something not so kewl
                      try this
                      date1 = now
                      date2 = date1.addYear(1 )

                      result everything 0 except for year... and day (also 1)

                      tried a little with other "year-add's"
                      90 -> year=90, day=1
                      99 -> year=99, day=0

                      wellwell, bug for small number of add years only?
                      or am I missing something?





                      "Atley" <atley_1@hotmai l.com> wrote in message
                      news:eY7io6S$DH A.3828@TK2MSFTN GP10.phx.gbl...[color=blue]
                      > Thanks, but i can get the DateDiff several different ways, the problem is
                      > with the breakdown into how much time is left as a rundown ie 1 year, 2
                      > months, 1 week, 3 days, 6 hours, 23 minutes, 41 seconds...
                      >
                      >
                      >
                      > "Dominique Vandensteen" <domi.vds_inser t@tralala_tenfo rce.com> wrote in
                      > message news:OK5fkhS$DH A.552@TK2MSFTNG P11.phx.gbl...[color=green]
                      > > something like this?
                      > >
                      > > dim date1 as datetime
                      > > dim date2 as datetime
                      > >
                      > > dim ticks1 as long = date1.ticks
                      > > dim ticks2 as long = date2.ticks
                      > >
                      > > dim difference as new timespan(math.a bs(ticks1 - ticks2))
                      > >
                      > >
                      > > Dominique
                      > >
                      > >
                      > >
                      > >
                      > > "Atley" <atley_1@hotmai l.com> wrote in message
                      > > news:OIitcQO$DH A.2040@TK2MSFTN GP12.phx.gbl...[color=darkred]
                      > > > I am trying to get a overall difference on two dates,
                      > > >
                      > > > I can get the difference in Years, Months, Weeks, Days, Hours,[/color][/color][/color]
                      Minutes,[color=blue][color=green][color=darkred]
                      > > > Seconds, no problems...
                      > > >
                      > > > What I cannot seem to figure out is how to get:
                      > > >
                      > > > 2 Years, 3 Months, 1 Week, 3 Days, 14 Hours, 21 Minutes, 33 Seconds.
                      > > >
                      > > > The hardest part of that, the part I cannot figure out, is the Month
                      > > > section... all the others are static, defined length components, but[/color]
                      > > Months[color=darkred]
                      > > > change, are all different...
                      > > >
                      > > > Help! anyone know how you do this? I am stuck...
                      > > >
                      > > > Thanks So Much for your Help!
                      > > >
                      > > > Atley
                      > > >
                      > > >[/color]
                      > >
                      > >[/color]
                      >
                      >[/color]


                      Comment

                      • Jay B. Harlow [MVP - Outlook]

                        #12
                        Re: Trying to get a Date Breakdown

                        Dominique,
                        You know you can shorten that to:
                        [color=blue]
                        > dim date1 as datetime
                        > dim date2 as datetime
                        >
                        > dim difference as timespan = date2.Subtract( date1)[/color]

                        Which assumes that date2 is after date1.

                        Hope this helps
                        Jay

                        "Dominique Vandensteen" <domi.vds_inser t@tralala_tenfo rce.com> wrote in
                        message news:OK5fkhS$DH A.552@TK2MSFTNG P11.phx.gbl...[color=blue]
                        > something like this?
                        >
                        > dim date1 as datetime
                        > dim date2 as datetime
                        >
                        > dim ticks1 as long = date1.ticks
                        > dim ticks2 as long = date2.ticks
                        >
                        > dim difference as new timespan(math.a bs(ticks1 - ticks2))
                        >
                        >
                        > Dominique
                        >
                        >
                        >
                        >
                        > "Atley" <atley_1@hotmai l.com> wrote in message
                        > news:OIitcQO$DH A.2040@TK2MSFTN GP12.phx.gbl...[color=green]
                        > > I am trying to get a overall difference on two dates,
                        > >
                        > > I can get the difference in Years, Months, Weeks, Days, Hours, Minutes,
                        > > Seconds, no problems...
                        > >
                        > > What I cannot seem to figure out is how to get:
                        > >
                        > > 2 Years, 3 Months, 1 Week, 3 Days, 14 Hours, 21 Minutes, 33 Seconds.
                        > >
                        > > The hardest part of that, the part I cannot figure out, is the Month
                        > > section... all the others are static, defined length components, but[/color]
                        > Months[color=green]
                        > > change, are all different...
                        > >
                        > > Help! anyone know how you do this? I am stuck...
                        > >
                        > > Thanks So Much for your Help!
                        > >
                        > > Atley
                        > >
                        > >[/color]
                        >
                        >[/color]


                        Comment

                        • Ron Allen

                          #13
                          Re: Trying to get a Date Breakdown

                          Dominique,
                          How about
                          Dim difference as TimeSpan = date2.Subtract( date1)
                          difference = difference.Dura tion() ' correct to positive offset
                          Now years is difference.Days/365 (ignoring leap year effects 365
                          days/year)
                          Days = difference.Days Mod 365
                          hours, minutes and seconds are directly readable from the timespan.

                          Ron Allen
                          "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP @msn.com> wrote in message
                          news:epj3HxT$DH A.3188@TK2MSFTN GP09.phx.gbl...[color=blue]
                          > Dominique,
                          > You know you can shorten that to:
                          >[color=green]
                          > > dim date1 as datetime
                          > > dim date2 as datetime
                          > >
                          > > dim difference as timespan = date2.Subtract( date1)[/color]
                          >
                          > Which assumes that date2 is after date1.
                          >
                          > Hope this helps
                          > Jay
                          >
                          > "Dominique Vandensteen" <domi.vds_inser t@tralala_tenfo rce.com> wrote in
                          > message news:OK5fkhS$DH A.552@TK2MSFTNG P11.phx.gbl...[color=green]
                          > > something like this?
                          > >
                          > > dim date1 as datetime
                          > > dim date2 as datetime
                          > >
                          > > dim ticks1 as long = date1.ticks
                          > > dim ticks2 as long = date2.ticks
                          > >
                          > > dim difference as new timespan(math.a bs(ticks1 - ticks2))
                          > >
                          > >
                          > > Dominique
                          > >
                          > >
                          > >
                          > >
                          > > "Atley" <atley_1@hotmai l.com> wrote in message
                          > > news:OIitcQO$DH A.2040@TK2MSFTN GP12.phx.gbl...[color=darkred]
                          > > > I am trying to get a overall difference on two dates,
                          > > >
                          > > > I can get the difference in Years, Months, Weeks, Days, Hours,[/color][/color][/color]
                          Minutes,[color=blue][color=green][color=darkred]
                          > > > Seconds, no problems...
                          > > >
                          > > > What I cannot seem to figure out is how to get:
                          > > >
                          > > > 2 Years, 3 Months, 1 Week, 3 Days, 14 Hours, 21 Minutes, 33 Seconds.
                          > > >
                          > > > The hardest part of that, the part I cannot figure out, is the Month
                          > > > section... all the others are static, defined length components, but[/color]
                          > > Months[color=darkred]
                          > > > change, are all different...
                          > > >
                          > > > Help! anyone know how you do this? I am stuck...
                          > > >
                          > > > Thanks So Much for your Help!
                          > > >
                          > > > Atley
                          > > >
                          > > >[/color]
                          > >
                          > >[/color]
                          >
                          >[/color]


                          Comment

                          • Atley

                            #14
                            Re: Trying to get a Date Breakdown

                            Sweet...

                            It works like a charm... you are the best! thanks for the help.




                            "Dominique Vandensteen" <domi.vds_inser t@tralala_tenfo rce.com> wrote in
                            message news:uSvUEgT$DH A.552@TK2MSFTNG P11.phx.gbl...[color=blue]
                            > aha
                            > you can do somthing like this...
                            >
                            >[color=green][color=darkred]
                            > > > dim date1 as datetime
                            > > > dim date2 as datetime
                            > > >
                            > > > dim ticks1 as long = date1.ticks
                            > > > dim ticks2 as long = date2.ticks
                            > > >[/color][/color]
                            > Dim dt As New DateTime(math.a bs(ticks1 - ticks2))
                            > Dim msg As String = "Differnce is:" & vbCrLf & _
                            > "years: " & (dt.Year - 1) & vbCrLf & _
                            > "months: " & (dt.Month - 1) & vbCrLf & _
                            > "days: " & (dt.Day - 1) & vbCrLf & _
                            > "hours: " & dt.Hour & vbCrLf & _
                            > "minutes: " & dt.Minute & vbCrLf & _
                            > "seconds: " & dt.Second
                            >
                            > doing -1 for year, month and day:
                            > new datetime(ticks as long) -> gives you a date, not a timespan
                            > and the date is calculated as the number of ticks since 01-01-0001[/color]
                            00:00:00[color=blue]
                            > so doing -1 for day, month and year gives you the remaining time for each
                            > datetime part
                            >
                            > isn't that kewl :-)
                            >
                            >
                            > something not so kewl
                            > try this
                            > date1 = now
                            > date2 = date1.addYear(1 )
                            >
                            > result everything 0 except for year... and day (also 1)
                            >
                            > tried a little with other "year-add's"
                            > 90 -> year=90, day=1
                            > 99 -> year=99, day=0
                            >
                            > wellwell, bug for small number of add years only?
                            > or am I missing something?
                            >
                            >
                            >
                            >
                            >
                            > "Atley" <atley_1@hotmai l.com> wrote in message
                            > news:eY7io6S$DH A.3828@TK2MSFTN GP10.phx.gbl...[color=green]
                            > > Thanks, but i can get the DateDiff several different ways, the problem[/color][/color]
                            is[color=blue][color=green]
                            > > with the breakdown into how much time is left as a rundown ie 1 year, 2
                            > > months, 1 week, 3 days, 6 hours, 23 minutes, 41 seconds...
                            > >
                            > >
                            > >
                            > > "Dominique Vandensteen" <domi.vds_inser t@tralala_tenfo rce.com> wrote in
                            > > message news:OK5fkhS$DH A.552@TK2MSFTNG P11.phx.gbl...[color=darkred]
                            > > > something like this?
                            > > >
                            > > > dim date1 as datetime
                            > > > dim date2 as datetime
                            > > >
                            > > > dim ticks1 as long = date1.ticks
                            > > > dim ticks2 as long = date2.ticks
                            > > >
                            > > > dim difference as new timespan(math.a bs(ticks1 - ticks2))
                            > > >
                            > > >
                            > > > Dominique
                            > > >
                            > > >
                            > > >
                            > > >
                            > > > "Atley" <atley_1@hotmai l.com> wrote in message
                            > > > news:OIitcQO$DH A.2040@TK2MSFTN GP12.phx.gbl...
                            > > > > I am trying to get a overall difference on two dates,
                            > > > >
                            > > > > I can get the difference in Years, Months, Weeks, Days, Hours,[/color][/color]
                            > Minutes,[color=green][color=darkred]
                            > > > > Seconds, no problems...
                            > > > >
                            > > > > What I cannot seem to figure out is how to get:
                            > > > >
                            > > > > 2 Years, 3 Months, 1 Week, 3 Days, 14 Hours, 21 Minutes, 33 Seconds.
                            > > > >
                            > > > > The hardest part of that, the part I cannot figure out, is the Month
                            > > > > section... all the others are static, defined length components, but
                            > > > Months
                            > > > > change, are all different...
                            > > > >
                            > > > > Help! anyone know how you do this? I am stuck...
                            > > > >
                            > > > > Thanks So Much for your Help!
                            > > > >
                            > > > > Atley
                            > > > >
                            > > > >
                            > > >
                            > > >[/color]
                            > >
                            > >[/color]
                            >
                            >[/color]


                            Comment

                            • Atley

                              #15
                              Re: Trying to get a Date Breakdown

                              Ron,

                              Yea that works, and that is pretty much what I was doing, except you have
                              the exact same problem with months that I did.


                              "Ron Allen" <rallen@_nospam _src-us.com> wrote in message
                              news:%23EK2v7T$ DHA.3536@TK2MSF TNGP10.phx.gbl. ..[color=blue]
                              > Dominique,
                              > How about
                              > Dim difference as TimeSpan = date2.Subtract( date1)
                              > difference = difference.Dura tion() ' correct to positive offset
                              > Now years is difference.Days/365 (ignoring leap year effects 365
                              > days/year)
                              > Days = difference.Days Mod 365
                              > hours, minutes and seconds are directly readable from the timespan.
                              >
                              > Ron Allen
                              > "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP @msn.com> wrote in message
                              > news:epj3HxT$DH A.3188@TK2MSFTN GP09.phx.gbl...[color=green]
                              > > Dominique,
                              > > You know you can shorten that to:
                              > >[color=darkred]
                              > > > dim date1 as datetime
                              > > > dim date2 as datetime
                              > > >
                              > > > dim difference as timespan = date2.Subtract( date1)[/color]
                              > >
                              > > Which assumes that date2 is after date1.
                              > >
                              > > Hope this helps
                              > > Jay
                              > >
                              > > "Dominique Vandensteen" <domi.vds_inser t@tralala_tenfo rce.com> wrote in
                              > > message news:OK5fkhS$DH A.552@TK2MSFTNG P11.phx.gbl...[color=darkred]
                              > > > something like this?
                              > > >
                              > > > dim date1 as datetime
                              > > > dim date2 as datetime
                              > > >
                              > > > dim ticks1 as long = date1.ticks
                              > > > dim ticks2 as long = date2.ticks
                              > > >
                              > > > dim difference as new timespan(math.a bs(ticks1 - ticks2))
                              > > >
                              > > >
                              > > > Dominique
                              > > >
                              > > >
                              > > >
                              > > >
                              > > > "Atley" <atley_1@hotmai l.com> wrote in message
                              > > > news:OIitcQO$DH A.2040@TK2MSFTN GP12.phx.gbl...
                              > > > > I am trying to get a overall difference on two dates,
                              > > > >
                              > > > > I can get the difference in Years, Months, Weeks, Days, Hours,[/color][/color]
                              > Minutes,[color=green][color=darkred]
                              > > > > Seconds, no problems...
                              > > > >
                              > > > > What I cannot seem to figure out is how to get:
                              > > > >
                              > > > > 2 Years, 3 Months, 1 Week, 3 Days, 14 Hours, 21 Minutes, 33 Seconds.
                              > > > >
                              > > > > The hardest part of that, the part I cannot figure out, is the Month
                              > > > > section... all the others are static, defined length components, but
                              > > > Months
                              > > > > change, are all different...
                              > > > >
                              > > > > Help! anyone know how you do this? I am stuck...
                              > > > >
                              > > > > Thanks So Much for your Help!
                              > > > >
                              > > > > Atley
                              > > > >
                              > > > >
                              > > >
                              > > >[/color]
                              > >
                              > >[/color]
                              >
                              >[/color]


                              Comment

                              Working...