Wednesday, April 20, 2011

Date project in vcpp

In VC++ 6.0 MFC application i am trying to Display date in Shot Format eg;05-10-09 but it will print 05-10-2009

Here is the code i written SYSTEMTIME st; GetSystemTime(&st);

CString str;

str.Format("%02d-%02d-%02d",st.wDay,st.wMonth,st.wYear); m_date=m_date + str;

I will get output say eg: 05-10-2009, but i want in this format 05-10-09

Plz any body help me

From stackoverflow
    1. it should be %02d-%02d-%02d, and not %02d-%02d-02%d
    2. The proper way should be using CTime::Format (I Don't know if VC 6 had that)
    3. pass (st.Year % 100)
  • ... "%02d", st.wYear % 100 ...

0 comments:

Post a Comment