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. DateTime problem???

DateTime problem???

Scheduled Pinned Locked Moved C#
helpquestion
2 Posts 2 Posters 0 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.
  • N Offline
    N Offline
    Neo Andreson
    wrote on last edited by
    #1

    I have two instance of DateTime structure, I want difference between these two dates in no. of days. Compair() is returning 1,-1 but not relative diff. Dateformat mm/dd/yy. Yhankxxxxxxx

    Truth Is The Simplest !!!!

    X 1 Reply Last reply
    0
    • N Neo Andreson

      I have two instance of DateTime structure, I want difference between these two dates in no. of days. Compair() is returning 1,-1 but not relative diff. Dateformat mm/dd/yy. Yhankxxxxxxx

      Truth Is The Simplest !!!!

      X Offline
      X Offline
      xString
      wrote on last edited by
      #2

      Try: DateTime dt1 = DateTime.Parse("01/01/2008 13:23"); DateTime dt2 = DateTime.Parse("01/01/2008 11:00"); TimeSpan ts = dt1.Subtract(dt2); or you could do: DateTime dt1 = DateTime.Parse("01/01/2008 13:00"); DateTime dt2 = DateTime.Parse("01/01/2008 11:00"); TimeSpan ts = dt1 - dt2; int days = ts.Days; int hrs = ts.Hours; int min = ts.Minutes; int sec = ts.Milliseconds;

      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