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
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?
"Paul Schouten" <email@example.com> schrieb im Newsbeitrag
> 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
// transfer data to locals
select = c_select.getcursel();
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
"Scott McPhillips [MVP]" <firstname.lastname@example.org> wrote in message
> 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?
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)
It doesn't seem to like this though if one of them or both of them are
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" <email@example.com> wrote in message
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
CTime timeTemp(sysTime.wYear, sysTime.wMonth, sysTime.wDay,
sysTime.wHour, sysTime.wMinute, sysTi...How to convert COleDateTime(or DATE) to tm structure?
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?
Does COleDateTime::Format() with the LOCALE_NOUSEROVERRIDE flag do what you
Microsoft MVP - Visual C++
"Meal" <firstname.lastname@example.org> wrote in message
> I need to format DATE into localized string. In our code base
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
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?
Try the following
COleDateTime dtCurrentDate ( COleDateTime::GetCurrentTime() );
AfxMessageBox( dtCurrentDate .Format( TEXT("%A %B %d, %Y
%H:%M") ) );
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.
COleDateTime low, today;
low.SetDate(2000, 1, 1);
but now, I have 1899-12-31 as minimum value and 2000-1-1 as maximum value :(
What is wrong?
GetCurrentTime doesn't work like you think it does
Do this to get today's date.
today = COleDateTime::GetCurrentTime();
...passing COleDateTime with lparam in postmessage
I am trying to pass a time value to another application.
Message that is sent:
curMsg.curTime = GetTheShow().GetShowTime();
} &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
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???
"Carlo" <carletto.m@NOSPAMgmail.com> wrote in message
> 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!
Why this function doesn't work on some computer
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.
"William Gower" <email@example.com> skrev i en meddelelse
> 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
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.
Refrigerated Transport Electronics, Inc.
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
>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)
printf("ct=%s\ncodt=%s\n", ct.Format("%m/%d/%Y %H:%M:%S"),
printf("ct secs from 1/1/1970=%I64d\n", ct.GetTime());
secs=(codt-COleDateTime(1970...COleDateTime:: Format method
I'm using the COleDateTime::Format method below:
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?
"Neil B" <NeilB@discussions.microsoft.com> wrote in message
> 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;
"Newbie & Noobie" <NewbieNoobie@discussions.microsoft.com> wrote in message
> 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
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!
You have to use Format(...) with the second parameter "LCID lcid" for german
CString strWeekDay = dt.Format(_T("%A"), MAKELCID(MAKELANGID(LANG_GERMAN,
You also need to have german locale installed on your PC.
"Fast Crack" <firstname.lastname@example.org> wrote in message
news:...COledateTime & time_t
I've a problem with this code :
unsigned long secondFrom1970 = 0;
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 ?
Would this solution work for you?
unsigned long secondFrom1970 = 0;
phys = time.Format();
"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
Take a look at the GetUserDefaultLCID() API.
"Mel Johnson" <email@example.com> wrote in message
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?"
On Sun, 4 Apr 2004 04:56:02 -0700, "Oleksiy Levit" <firstname.lastname@example.org>
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,
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...