Trying to get a Date Breakdown

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

    #16
    Re: Trying to get a Date Breakdown

    What is a year? What is a month?

    Peter Seaman


    Comment

    • Dominique Vandensteen

      #17
      Re: Trying to get a Date Breakdown

      well I used the dateTime and not the TimeSpan just to have an easy way to
      find the years, months and days...


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