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. Compare input date with current date!

Compare input date with current date!

Scheduled Pinned Locked Moved C / C++ / MFC
c++csstutorialquestion
5 Posts 3 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.
  • K Offline
    K Offline
    krajah10
    wrote on last edited by
    #1

    Hi' I'm new to C++? This code to show current date. #include #include "string.h" #include "time.h" #include int main() { tdclass TimeDateClass; cout<<"Today is "<<TimeDateClass.date()<<endl; system("pause"); } How to compare date we input and compare is it less or more from the current date? Tq

    N J 2 Replies Last reply
    0
    • K krajah10

      Hi' I'm new to C++? This code to show current date. #include #include "string.h" #include "time.h" #include int main() { tdclass TimeDateClass; cout<<"Today is "<<TimeDateClass.date()<<endl; system("pause"); } How to compare date we input and compare is it less or more from the current date? Tq

      N Offline
      N Offline
      Nishad S
      wrote on last edited by
      #2

      One idea is to convert the dates to corresponding number of days and compare.

      - NS - [ODBaseBtn]

      K 1 Reply Last reply
      0
      • K krajah10

        Hi' I'm new to C++? This code to show current date. #include #include "string.h" #include "time.h" #include int main() { tdclass TimeDateClass; cout<<"Today is "<<TimeDateClass.date()<<endl; system("pause"); } How to compare date we input and compare is it less or more from the current date? Tq

        J Offline
        J Offline
        Jijo Raj
        wrote on last edited by
        #3

        You can use COleDateTime[^] class. It have comparison operators such as ==, <, <=, etc[^] which can be used for comparison. Regards, Jijo.

        _____________________________________________________ http://weseetips.com[^] Visual C++ tips and tricks. Updated daily.

        1 Reply Last reply
        0
        • N Nishad S

          One idea is to convert the dates to corresponding number of days and compare.

          - NS - [ODBaseBtn]

          K Offline
          K Offline
          krajah10
          wrote on last edited by
          #4

          Can you show me more details!

          N 1 Reply Last reply
          0
          • K krajah10

            Can you show me more details!

            N Offline
            N Offline
            Nishad S
            wrote on last edited by
            #5

            For example, days1 = day1 + month1*31 + year1*365; days2 = day2 + month2*31 + year2*365; if( days1 > days2 ) { do something } else { do something }

            - NS - [ODBaseBtn]

            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