How to convert datetime to double VC++ in order

TeeChart for ActiveX, COM and ASP
Post Reply
GLSWG
Newbie
Newbie
Posts: 39
Joined: Fri Jan 09, 2004 5:00 am

How to convert datetime to double VC++ in order

Post by GLSWG » Fri Feb 20, 2004 3:32 pm

to use it in CalcXPosValue(somedouble_from_datetime)?

I saw the way to do it in Delphi by 'EncodeDate()' function, but how about VC++?
Any ideas would be gretly appreciated. Thanks.

Igor.

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Mon Feb 23, 2004 9:26 am

Hi,

in VC++, TeeChart uses a COleDateTime object to define datetime, e.g.

COleDateTime datevalue;
datevalue = COleDateTime(doublevalue);

GLSWG
Newbie
Newbie
Posts: 39
Joined: Fri Jan 09, 2004 5:00 am

Post by GLSWG » Mon Feb 23, 2004 3:57 pm

Hi,
Thank you for reply. But actually I need a reverse operation to be done - get a double from COleDateTime. I have my bottom axes as of date type. And I need to know a real coordinates those correspond to certain dates on bottom axes. To achive this I guess I need to use function CalcXPos(double). So I need that certain date on bottom axes to be coverted in double in order to use it in CalcXPos function. Any ideas?

Thanks.

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Tue Feb 24, 2004 11:17 am

Hi,

how about using DOUBLE(x):

DoubleValue = DOUBLE(COleDateTimeValue);

?

GLSWG
Newbie
Newbie
Posts: 39
Joined: Fri Jan 09, 2004 5:00 am

Post by GLSWG » Sat Feb 28, 2004 9:23 pm

Hi,
Actually I did not find that macro DOUBLE(x) in VC++ documentation, but on the other hand it gace me an idea and below is how I solved my conversion problem via ChangeType function:

Code: Select all

COleVariant oleDateVar;
		oleDateVar.ChangeType(VT_DATE);
		COleDateTime oleDate(nYear, nMonth, nDay, 12, 0, 0);
		oleDateVar = oleDate;
		
		oleDateVar.ChangeType(VT_R8);
		nDoubleDateValue = V_R8(&oleDateVar);
long nX = cBottomAxis.CalcXPosValue(nDoubleDateValue/100.0);
However it seems converted it not exactly to the double which was used by chart when building Bottom axis datevalue for that date. So I should devide it by 100 to get some approximate coordinate to what is really needed. But still it's not the exact value. Have you an idea how to get exact value which exactly corresponds to the coordinate on bottom axis?

Thank you again for your time.

GLSWG
Newbie
Newbie
Posts: 39
Joined: Fri Jan 09, 2004 5:00 am

Post by GLSWG » Mon Mar 01, 2004 12:17 am

Hi,
An issue is off for now, I have found what was the problem. Anyway thank you for your help.

Igor.

Post Reply