Tech Support Guy banner
Status
Not open for further replies.
1 - 3 of 3 Posts

·
Registered
Joined
·
24 Posts
Discussion Starter · #1 ·
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
 

·
Registered
Joined
·
400 Posts
oh and as for the other questions, using ParseDateTime with a locale id probably overrides the SetFormat settings. Advantages of ParseDateTime is that its one method to specify date rather than 3 assigns u were originally doing plus u get the benefit of using LANG_USER_DEFAULT to use regional settings on the persons pc running your program.
 
1 - 3 of 3 Posts
Status
Not open for further replies.
Top