Platform : VC++.NET/6.0
App: MDI app using a pair of Dialogs
Problem:
CDateTimeCtrl not displaying values correctly.
Scenario:
trying to retrieve date values directly from a listview control which has values fetched from a database.
WORKING code:
strDate=m_ctlList.GetItemText(nCurrRow,3);//placing value from listview into //a CString
//converting the values to numbers
nDay=atoi(strDate.Left(2));
nMon=atoi(strDate.Mid(3,2));
nYear=atoi(strDate.Right(4));
//setting the value in COleDateTime variable
codtDDate.SetDate(nYear,nMon,nDay);
====================================================
however i decided that took too many function calls and
started to use the ParseDateTime() function like so......
(1033 = English Locale ID)
codtDDate.ParseDateTime(strDate,VAR_DATEVALUEONLY,1033);
====================================================
the values im getting a screwy output with is "04-06-2005" (thats how it appears in the Listview : DD-MM-YYYY)
parsedatetime flips it over to read the 6th of April,2005(06/04/2005) instead of the 4th of June.
ADDITION: the Dialog in which im displaying the retrieved values in a CDateTimeCtrl .... contains following in the OnInitDialog()
//m_dtpBorrowed = Control variable for CDateTimeCtrl
m_dtpBorrowed.SetFormat("dd/MM/yyyy");
....
any suggestions welcome
- it'd be helpful if someone could tell me what are the advantages of ParseDateTime() ?? over the manual way i m using