COleDateTime ???

I have a form with 3 controls on it. They are a Combo box, a date picker and 
a submit button. I added control variables for the combo box and the date 
picker and add a function for the submit button. The control variables are 
c_select, c_date. When the submit button is pressed I want to transfer the 
info in the controls to the document.
So in the function I added code 

// local variables to make sure I am getting what I want
int select;	
COleDateTime date;

// transfer data to locals
select = c_select.getcursel();
c_date ??????????????????????????????????????????????

now how can I get the COleDateTime data to a local variable from a control 
variable on the form?

-- 
Just Al
0
Al1 (451)
3/1/2008 2:46:02 PM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
938 Views

Similar Articles

[PageSpeed] 3

Have a look at CDateTimeCtrl::GetTime method in MSDN:

if(c_date.GetTime(date))
{
   //    do what you want with this date/time
    ...
}

Victor

"Al" <Al@discussions.microsoft.com> wrote in message 
news:2A617D62-3262-46D2-A790-588D29864C52@microsoft.com...
>I have a form with 3 controls on it. They are a Combo box, a date picker 
>and
> a submit button. I added control variables for the combo box and the date
> picker and add a function for the submit button. The control variables are
> c_select, c_date. When the submit button is pressed I want to transfer the
> info in the controls to the document.
> So in the function I added code
>
> // local variables to make sure I am getting what I want
> int select;
> COleDateTime date;
>
> // transfer data to locals
> select = c_select.getcursel();
> c_date ??????????????????????????????????????????????
>
> now how can I get the COleDateTime data to a local variable from a control
> variable on the form?
>
> -- 
> Just Al 


0
3/1/2008 5:43:42 PM
Thanks Victor

Works great.

-- 
Just Al


"Victor" wrote:

> Have a look at CDateTimeCtrl::GetTime method in MSDN:
> 
> if(c_date.GetTime(date))
> {
>    //    do what you want with this date/time
>     ...
> }
> 
> Victor
> 
> "Al" <Al@discussions.microsoft.com> wrote in message 
> news:2A617D62-3262-46D2-A790-588D29864C52@microsoft.com...
> >I have a form with 3 controls on it. They are a Combo box, a date picker 
> >and
> > a submit button. I added control variables for the combo box and the date
> > picker and add a function for the submit button. The control variables are
> > c_select, c_date. When the submit button is pressed I want to transfer the
> > info in the controls to the document.
> > So in the function I added code
> >
> > // local variables to make sure I am getting what I want
> > int select;
> > COleDateTime date;
> >
> > // transfer data to locals
> > select = c_select.getcursel();
> > c_date ??????????????????????????????????????????????
> >
> > now how can I get the COleDateTime data to a local variable from a control
> > variable on the form?
> >
> > -- 
> > Just Al 
> 
> 
> 
0
Al1 (451)
3/2/2008 4:05:02 PM
Reply:

Similar Artilces:

COleDateTime Confusion
Using the code COleDateTime Date1( 2003 , 8 , 31 , 0 , 0 , 0 ); COleDateTime Date2( 2003 , 8 , 1 , 0 , 0 , 0 ); COleDateTimeSpan DateDifference = Date1 - Date2; sprintf( aux , "From %s to %s is %s days" , (LPCTSTR) Date2.Format( "%B %d %Y" ) , (LPCTSTR) Date1.Format( "%B %d %Y" ) , (LPCTSTR) DateDifference.Format( "%d" ) ); pdc->TextOut( 100 , currow - 2*rowHeight , aux ); the program displays that the difference is 29 days. My quick calculation usi...

From CDateTimeCtrl to COleDateTime, plz help me
Hey, I have a question about CDateTimeCtrl, I have a form-view with a CDateTimeCtrl control where the user can select a date (long format). Now i want to store the date the user selected in a COleDateTime object, how do i get the date from the CDateTimeCtrl into the COleDateTime variable? cheers, Paul "Paul Schouten" <vincent_schouten@yahoo.com> schrieb im Newsbeitrag news:42e21af6$0$97483$e4fe514c@news.xs4all.nl... > Hey, > > I have a question about CDateTimeCtrl, I have a form-view with a > CDateTimeCtrl control where the user can select a date (long fo...

COleDateTime ???
I have a form with 3 controls on it. They are a Combo box, a date picker and a submit button. I added control variables for the combo box and the date picker and add a function for the submit button. The control variables are c_select, c_date. When the submit button is pressed I want to transfer the info in the controls to the document. So in the function I added code // local variables to make sure I am getting what I want int select; COleDateTime date; // transfer data to locals select = c_select.getcursel(); c_date ?????????????????????????????????????????????? now how can I get th...

COleDateTime Comparison
How do I compare 2 COleDateTime objects? Do I have to format them as CStrings and then CompareNoCase() or is there a better way? Sometimes the date field may be empty, how do I allow for the in the comparison. I am getting an error because of comparing a date field with an empty field. "Scott McPhillips [MVP]" <scottmcp@mvps.org> wrote in message news:OFI68ARhDHA.2192@TK2MSFTNGP09.phx.gbl... > William Gower wrote: > > > How do I compare 2 COleDateTime objects? Do I have to format them as > > CStrings and then CompareNoCase() or is there a better way? &g...

COleDateTime Issue
Hi All, MS DTP Control is implemented such that, if a) you type in 2 digit year, it takes it as 20XX where XX is the year you entered is <=29. b) you type in 2 digit year, it takes it as 19XX where XX is the year you entered is >=30. As soon as user types a 2 digit year in MS DTp control, it automatically converts it to 19XX or 20XX depending upon what user wrote. So, even if I do an UpdateData() and get the value to a contrl variable .. I get the 4 digit value and not a 2 digit ... and there is no way for me to know thatuser typed a 2digit year(which MS control automatically u...

COleDateTime
I have a compare routine that compares 2 COleDateTime field members. The problem is that one of them or both of them might be empty. If(pBear1->m_BirthDate > pBear2->m_BirthDate) return 1 else return -1 It doesn't seem to like this though if one of them or both of them are blank. This depends on the requirements of your app. You should also take into consideration the status of COleDateTime via GetStatus() -- in debug mode, the compare will assert if the date/time is not valid. "William Gower" <w_gower@hotmail.com> wrote in message news:egdY5w2...

COleDateTime Question
Hi. I have an internal API that expects a time/date as a DWORD, but I've read the time from a data file as a COleDateTime (actually as a double to start with). What is the most efficient way to convert between the time as a double to the time as a DWORD? I have this code working, but it seems a little long-winded: double dTime = 37064.7269907; // Actually read from file, but simplified for here... COleDateTime oleTime(dTime); SYSTEMTIME sysTime; oleTime.GetAsSystemTime(sysTime); CTime timeTemp(sysTime.wYear, sysTime.wMonth, sysTime.wDay, sysTime.wHour, sysTime.wMinute, sysTi...

How to convert COleDateTime(or DATE) to tm structure?
Hi, I need to format DATE into localized string. In our code base there's such function but it needs a tm as input, so I need to convert DATE into tm to use this function. Is there a way to do that? Or if I can go around? Thanks, Meal. Does COleDateTime::Format() with the LOCALE_NOUSEROVERRIDE flag do what you need? Mark -- Mark Salsbery Microsoft MVP - Visual C++ "Meal" <meedeex@gmail.com> wrote in message news:1193674366.295581.83940@e34g2000pro.googlegroups.com... > Hi, > I need to format DATE into localized string. In our code base > there...

COleDateTime::Format
Hi all Recently we start migrating from VC 6.0 to VS 2005 We have the following problem: for one reason or another we save in the DB dates that are represented as 0 (COleDateTime::m_dt is zero). later on when we try to print this date using this COleDateTime::Format(_T("%Y.%m.%d %H:%M")) I get an error and the process is terminated. I check the code of COleDateTime::Format and I saw this: tmTemp.tm_year = ud.st.wYear - 1900; which result in negative tm_year (zero represent date that is in year < 1900). which is incorrect param for _tcsftime (_tcsftime is used from COleDateT...

COleDateTime Format
How can I format a COleDateTime so it appears in Long Format but without the seconds (this needs to run in the current local) For example "%#c" give me something like Friday February 24th 2003, 10:34:00 and what I want is Friday February 24th 2003, 10:34 Any ideas please? -- Michael Tissington http://www.tabtag.com http://www.oaklodge.com Try the following COleDateTime dtCurrentDate ( COleDateTime::GetCurrentTime() ); AfxMessageBox( dtCurrentDate .Format( TEXT("%A %B %d, %Y %H:%M") ) ); -- Cheers Check Abdoul [VC++ MVP] -----------------------...

COleDateTime and SetRange
I have a CDateTimeCtrl control and I need to set minimum and maximum date. How can I set maximum value of COleDateTime object? I need to set maximum value to tommorow date and minimum value to 2000-01-01. I have: COleDateTime low, today; today.GetCurrentTime(); low.SetDate(2000, 1, 1); //CDateTimeCtrl m_DateCTRL m_DateCTRL.SetRange(&low, &today); but now, I have 1899-12-31 as minimum value and 2000-1-1 as maximum value :( What is wrong? ArtuS GetCurrentTime doesn't work like you think it does Do this to get today's date. today = COleDateTime::GetCurrentTime(); Ali R. ...

passing COleDateTime with lparam in postmessage
I am trying to pass a time value to another application. Message that is sent: struct sendMsg{ COleDateTime curTime; CString namedView; } curMsg; curMsg.curTime = GetTheShow().GetShowTime(); ::PostMessage(HWND_BROADCAST, wm_Message, (WPARAM) m_hWnd, (LONG) &curMsg); Message received: struct recMsg{ COleDateTime curTime; CString namedView; } &in =*(recMsg*) lParam; currentTime = in.curTime //currentTime is COleDateTime I am obviously casting incorrectly. I could put value in a string if that is eas...

COleDateTime #2
hi i need to manage date time with millisecond, thus i create a class derived from COleDateTime, i need now to add a number of seconds to my datatime, i read the help but i dont find an add function, have i to create it??? or have i to learn reading help online??? thanks carlo "Carlo" <carletto.m@NOSPAMgmail.com> wrote in message news:O918A5IvGHA.4972@TK2MSFTNGP05.phx.gbl > i need to manage date time with millisecond, thus i create a class > derived from COleDateTime, i need now to add a number of seconds to > my datatime, i read the help but i dont find an add ...

Please Help! COleDateTime in VC++ 6.0
I am using VC++ 6.0 in Win 2000 When I try to use the COleDateTime function in the app StringTmp = COleDateTime(vExpirationDate).Format(_T("%d.%m.%y %H:%M:%S")); I get the error msg on some computers the msg is "Debug Assertion Failed! File: afxwin1.in Line:2 Why this function doesn't work on some computer thank you Pol Hello Pola, Thanks for your post. I reviewed your description carefully, and I think more information is needed before moving forward: What's the value for vExpirationDate? Did you build your program with _UNICODE? What are the computers which ...

Setting COleDateTime to blank
There must be a way to set a COleDateTime object to blanks after it has a date already assigned to it. I believe you are talking about a CDateTimeCtrl. If so, you should be able to do it by calling SetTime() on it, without parameters. -- Bjarne Nielsen "William Gower" <w_gower@hotmail.com> skrev i en meddelelse news:%232dlk9BmDHA.1004@TK2MSFTNGP09.phx.gbl... > There must be a way to set a COleDateTime object to blanks after it has a > date already assigned to it. > > ...

Help about COleDateTime::ParseDateTime
As you know, COleDateTime::ParseDateTime can parse a time string to date/time value, and supports variety of time formats. My problem is, if I input a time string "2007/11/01 13:00am" which is not a acceptable time format because the hour value(13) must not over 12, but COleDateTime::ParseDateTime returns date/time value "2007/11/01 13:00" successfully. So how can i detect this unacceptable time format with different locale settings, or any other ALT/MFC Class can be used to detect this kind of unacceptable format? thank you. "Ronnie" <Ronnie@discussion...

CTime/COleDateTime status
Re: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=147311&SiteID=1 Is there going to be an update to solve this problem, or is there one I can request? As I've indicated, the posted work-around fails to compile on PPC2003/WM5. JAB -- John Belli Software Engineer Refrigerated Transport Electronics, Inc. Hi John, Thank you posting! For the issues about the mobile device platform development, I suggest you consult it in more appropriate newsgroups, you'd get better and quicker help there: microsoft.public.windowsce.embedded.vc >Is there going to be an update to so...

CTime and COleDateTime differences WHY??
Using .NET 2003 Porting code from CTime to COleDateTime. I am trying to get "seconds from Jan 1, 1970", but i get different results. The difference is eight hours (28800 seconds). Can anyone explain what i am doing wrong? Here is my code: int _tmain(int argc, _TCHAR* argv[]) { CTime ct(2005,11,25,0,0,0); COleDateTime codt(2005,11,25,0,0,0); printf("ct=%s\ncodt=%s\n", ct.Format("%m/%d/%Y %H:%M:%S"), codt.Format("%m/%d/%Y %H:%M:%S")); printf("ct secs from 1/1/1970=%I64d\n", ct.GetTime()); __time64_t secs; secs=(codt-COleDateTime(1970...

COleDateTime:: Format method
I'm using the COleDateTime::Format method below: m_date.Format("%m/%d/%Y") when the month or day fields are a single digit the are formatted with leading blanks (ie. " 5/ 4/2006"). What I want is "5/4/2006". Is there some way to supress the leading blanks in these fields? Thanks, Neil Try: m_date.Format("%#m/%#d/%Y"); Victor "Neil B" <NeilB@discussions.microsoft.com> wrote in message news:83F9C728-BE11-4EF6-AE2C-93F790273E17@microsoft.com... > I'm using the COleDateTime::Format method below: > > m_date.Format(&q...

Convert COleDateTime to Double
How do I convert a Double to COleDateTime I know how to convert COleDateTime to Double, using the following code double XX = DateTime.m_dt; But what is the coding to convert back; Thanks Guys. Regards, Jimmy "Newbie & Noobie" <NewbieNoobie@discussions.microsoft.com> wrote in message news:498FCE41-07A2-4AFA-AFB6-C7669F12EF44@microsoft.com... > How do I convert a Double to COleDateTime > > I know how to convert COleDateTime to Double, using the following code > double XX = DateTime.m_dt; > > But what is the coding to convert back; > If you have a...

COleDateTime.Format
Hay! I want to get the Day of Week in german. I've used COleDateTime.Format("%A") but I always got 'Sunday' instead of 'Sonntag'. What have i to do to get the german weekday! thx Martin Hi! You have to use Format(...) with the second parameter "LCID lcid" for german locale: COleDateTime dt(...); CString strWeekDay = dt.Format(_T("%A"), MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), SORT_DEFAULT)); You also need to have german locale installed on your PC. Gru´┐Ż Victor "Fast Crack" <fcrx@hotmail.com> wrote in message news:...

COledateTime & time_t
Hello all, I've a problem with this code : -- unsigned long secondFrom1970 = 0; COleDateTime time((time_t)secondFrom1970); CString phys; phys = time.Format(); -- I want to see 01/01/1970 00:00.00 but program shows 01/01/1970 01:00.00. I believe that depends on the fuse(GMT+1). How can it be independent from the fuse ? thanks Stefano Magni Would this solution work for you? _tzset(); unsigned long secondFrom1970 = 0; COleDateTime time((time_t)secondFrom1970+_timezone); CString phys; phys = time.Format(); AliR. "Stefano Magni" <StefanoMagni@discussions.microso...

COleDateTime parsing string
I have to parse date/time strings that are available in this format: 2005-10-13T07:00:00Z (represents 7am on Oct 13) 2005-10-13T014:00:00Z (represents 2pm on Oct 13) The user's locale can be anything (US, UK etc) When I call COleDateTime::ParseDateTime, it fails with the default LCID. Does anyone know which LCID I should use to parse date/times is the above format? Thanks! Take a look at the GetUserDefaultLCID() API. -- Cheers Check Abdoul ----------------- "Mel Johnson" <test@test.com> wrote in message news:uAYYMHC0FHA.2752@TK2MSFTNGP12.phx.gbl... &g...

COleDateTime::GetCurrentTime() problem
COleDateTime::GetCurrentTime() causes the following error message Unhandled exception in Application (MFCO42D.DLL) :0xC00000005: Access Violation This problem appears only in debug version of my program. Where does it happen, what is the last operation you called? It sounds suspiciously like memory damage and most likely coming from the heap routines, but that's just a guess, since this isn't much more information than "My program broke, what's wrong?" joe On Sun, 4 Apr 2004 04:56:02 -0700, "Oleksiy Levit" <anonymous@discussions.microsoft.com> wrot...

COleDateTime::Format and language
Hello everybody. I'm using COleDateTime::Format() with "%B %Y" (full month name and year) and it gives me the month name in English, I need this name in same language than Windows (Spanish in my case), how can I do this? or COleDateTime::Format() always gives the names in English? Thanks in advance, William GS Are you running on a Spanish build of Windows? If so, you should get the appropriate language. If you are running under English Windows I believe you will have to built the time yourself using your own strings from localized resources. You can check the locale to...