Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Getting The Difference Between Months

Getting The Difference Between Months

Scheduled Pinned Locked Moved C#
csharphelp
3 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zoroyster
    wrote on last edited by
    #1

    Hi, Im trying to create a C# program that will compute the exact number of months between two durations. This is my code TimeSpan duration = startTime - stopTime; //to compute the difference between days, I use this code int result = (duration.Days); unfortunately it stops with duration.Days.. there are no available methods that will compute the months or years (eg. duration.Months , duration.Years) i tried to compute the days and divide it by 30, but this approach is highly innacurate. Hope you guys can help tnx

    H 1 Reply Last reply
    0
    • Z zoroyster

      Hi, Im trying to create a C# program that will compute the exact number of months between two durations. This is my code TimeSpan duration = startTime - stopTime; //to compute the difference between days, I use this code int result = (duration.Days); unfortunately it stops with duration.Days.. there are no available methods that will compute the months or years (eg. duration.Months , duration.Years) i tried to compute the days and divide it by 30, but this approach is highly innacurate. Hope you guys can help tnx

      H Offline
      H Offline
      Harini N K
      wrote on last edited by
      #2

      Hi Check this link http://www.c-sharpcorner.com/UploadFile/DipalChoksi/DateDiff_CS_DC09132006172429PM/DateDiff_CS_DC.aspx[^]

      Harini

      Z 1 Reply Last reply
      0
      • H Harini N K

        Hi Check this link http://www.c-sharpcorner.com/UploadFile/DipalChoksi/DateDiff_CS_DC09132006172429PM/DateDiff_CS_DC.aspx[^]

        Harini

        Z Offline
        Z Offline
        zoroyster
        wrote on last edited by
        #3

        Hi harini. Thanks for the reply. Ive read the link, but it doesn't mention anything about getting the difference between two dates in months :c Hope you have other references.. tnx!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups