Question : CMonthCalCtrl.GetCurSel() returns date 2 years off

I'm using the MFC CMonthCalCtrl for a small app.

It works across several of our clients, except for one.

GetCurSel returns a date 2 years, 7 months, and 9 days ahead of the date selected.

Answer : CMonthCalCtrl.GetCurSel() returns date 2 years off

The Month Calendar seems to act weird if you don't access it in a certain way. One way you can get good dates out of it is if I use SYSTEMTIME in lieu of CTime or whatever.

Try the following with SYSTEMTIME:

      CString pDate;
      SYSTEMTIME ct;
   

      if( m_dateStart.GetCurSel(dateTime) )
      {
            pDate.Format(_T("%02d/%02d/%2d"),ct.wMonth ,ct.wDay, ct.wYear );
            AfxMessageBox(pDate); // just for testing
      }

Hope this helps
-MAHESH
Random Solutions  
 
programming4us programming4us