|
-
July 30th, 2003, 02:25 PM
#1
Need faster replacement for COleDateTime::Format()
I have an app which manipulates a lot of dates (reading from a database).
It uses the Format() member function of COleDateTime extensively.
During a recent profiling session, it became apparent that a large amount of my app's time is spent in the Format() function.
Here's how I'm using it:
Code:
COleDateTime date1 = x.Format("%m/%d/%Y");
Simple, yes. But very expensive in terms of CPU time.
Does anyone have a faster way to do this?
-
July 30th, 2003, 02:34 PM
#2
try this:
std::stringstream x;
x << date1.GetMonth() << "/" << date1.GetDay() << "/" << date1.GetYear();
-
July 30th, 2003, 02:40 PM
#3
Oops, I realized I wrote my post wrong
should have been:
I have an app which manipulates a lot of dates (reading from a database).
It uses the Format() member function of COleDateTime extensively.
During a recent profiling session, it became apparent that a large amount of my app's time is spent in the Format() function.
Here's how I'm using it:
Code:
CString date1 = x.Format("%m/%d/%Y");
(x is a COleDateTime variable)
Simple, yes. But very expensive in terms of CPU time.
Does anyone have a faster way to do this?
-
July 30th, 2003, 03:40 PM
#4
Why not have the provider convert it to a string for you? When binding you accessor just change the type to DBTYPE_STR.
-
July 31st, 2003, 05:29 AM
#5
I probably didn't explain correctly
For this discussion, let's forget that the values are in a database.
I still have to do a lot of format()s outside of the database access stuff.
And the OLE DB library I use requires me to read dates as dates, not as strings.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|