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 current date with listed date

compare current date with listed date

Scheduled Pinned Locked Moved C / C++ / MFC
csshelpquestion
4 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.
  • S Offline
    S Offline
    shaans
    wrote on last edited by
    #1

    hai anybdy can help me.i have some keys that generated and stored in to text file. That key contain name and two dates like start date and end date.so now i want to compare the key with the given or enterd name is present in that txt file and if present compare the currentdate with dates given in the key.and give boolen like the current date exceed the end date or not? and start date less than the current date. can any body help me? regards shaanu

    T 1 Reply Last reply
    0
    • S shaans

      hai anybdy can help me.i have some keys that generated and stored in to text file. That key contain name and two dates like start date and end date.so now i want to compare the key with the given or enterd name is present in that txt file and if present compare the currentdate with dates given in the key.and give boolen like the current date exceed the end date or not? and start date less than the current date. can any body help me? regards shaanu

      T Offline
      T Offline
      ThatsAlok
      wrote on last edited by
      #2

      What is format of your date i.e. YYYY/MM/DD or something else.....


      [Vote One Here, Complete my Survey....] Alok Gupta
      visit me at http://www.thisisalok.tk          "I Think Believe this Will Help"

      S 1 Reply Last reply
      0
      • T ThatsAlok

        What is format of your date i.e. YYYY/MM/DD or something else.....


        [Vote One Here, Complete my Survey....] Alok Gupta
        visit me at http://www.thisisalok.tk          "I Think Believe this Will Help"

        S Offline
        S Offline
        shaans
        wrote on last edited by
        #3

        my date format is DD/MM/yyyy.can u help me? shan

        T 1 Reply Last reply
        0
        • S shaans

          my date format is DD/MM/yyyy.can u help me? shan

          T Offline
          T Offline
          ThatsAlok
          wrote on last edited by
          #4

          here is small code that compare current date with your stored date. My date Format is YYYY-MM-DD, i Believe,you are smart Enough to modify the code according to your need.

          BOOL ::FnCheckForValidDates(CString szEndDate)
          {

          //Get Current date
          CTime TodayDate=CTime::GetCurrentTime();
          
          int nYear,nMonth,nDay;
          //date format YYYY-MM-DD
          
          ///Extract Year
          nYear=\_ttoi(szEndDate.Left(szEndDate.Find('-')));
          
          ///remove the Year from String
          	szEndDate.Replace(szEndDate.Left(szEndDate.Find('-')),"");
          ///Replace Extra '-'
          	szEndDate.TrimLeft('-');
          

          ///Extract Month
          nMonth=_ttoi(szEndDate.Left(szEndDate.Find('-')));

          ///remove the Year from String
          	szEndDate.Replace(szEndDate.Left(szEndDate.Find('-')),"");
          ///Replace Extra '-'
          	szEndDate.TrimLeft('-');
          
          ///Extract Day
          	nDay=\_ttoi(szEndDate);
          
          
          ///comparison Routine
          ///first Check year
          
          	if(TodayDate.GetYear()>nYear)
          		return FALSE;
          
          	if(TodayDate.GetMonth()>nMonth)
          		return FALSE;
          
          	if(TodayDate.GetDay()>nDay)
          		return FALSE;
          

          #ifdef MYDEBUG
          AfxMessageBox("Returning True");
          #endif

          return TRUE;
          

          }


          [Vote One Here, Complete my Survey....] Alok Gupta
          visit me at http://www.thisisalok.tk          "I Think Believe this Will Help"

          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