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 / C++ / MFC
  4. DATEDIFF function

DATEDIFF function

Scheduled Pinned Locked Moved C / C++ / MFC
c++database
4 Posts 4 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.
  • E Offline
    E Offline
    ElCachubrey
    wrote on last edited by
    #1

    Hi Is exists in c++ a function similar to DATEDIFF in SQL or VB THANK

    C B V 3 Replies Last reply
    0
    • E ElCachubrey

      Hi Is exists in c++ a function similar to DATEDIFF in SQL or VB THANK

      C Offline
      C Offline
      CPallini
      wrote on last edited by
      #2

      If you're using MFC, have a look at CTimeSpan class http://msdn2.microsoft.com/en-us/library/ay6ws8h3(VS.80).aspx[^]. :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.

      1 Reply Last reply
      0
      • E ElCachubrey

        Hi Is exists in c++ a function similar to DATEDIFF in SQL or VB THANK

        B Offline
        B Offline
        benjymous
        wrote on last edited by
        #3

        CompareFileTime is a win32 function that'll compare two FILETIME structs

        1 Reply Last reply
        0
        • E ElCachubrey

          Hi Is exists in c++ a function similar to DATEDIFF in SQL or VB THANK

          V Offline
          V Offline
          vladfein
          wrote on last edited by
          #4

          Unfortunately, none of the two suggestion above will do what DATEDIFF does... You need to separate the DATE part of your time value. You didn't say what data type you use for your date/time variables. The easiest way, I think, is to convert both dates to COleDateTime (which wraps double representation of date/time), truncate the fractional part and simply subtract one value from another.

          ----------------------------- Get trial copy of FeinViewer - an integrated GDI objects viewer for Microsoft Visual Studio .NET 2005 (8.0) Visual C++ Debugger, and other convenience and productivity tools for Microsoft Visual Studio .NET at at www.FeinSoftware.com

          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