FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour XHarbour TOleAuto Dates Bug
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
XHarbour TOleAuto Dates Bug
Posted: Mon Mar 30, 2009 08:28 AM
I have encountered a new bug with the recent XHarbour ( released along with FWH ) TOleAuto class. The Dates written and read are different by 1 millisecond and hence date equality comparisons are going wrong. ( I confirm that this was working perfectly in the version I used six months back ). This is the problem with Excel, Access, or any RDBS accessed through ADO.

For example, if the data stored in the table ( or Excel sheet ) is 12th Aug 2009, the value read is 12th Aug 2009 PLUS one millisecond. Here is a test program:
Code (fw): Select all Collapse
#include "fivewin.ch"

function Main()
   local oExcel, oBook, oSheet
   local dWrite, dRead

   SET DATE ITALIAN
   SET CENTURY ON

   oExcel   := CreateObject( "Excel.Application" )
   oBook    := oExcel:WorkBooks:Add()
   oSheet   := oExcel:ActiveSheet

   dWrite        := STOD( "20090812" )
   oSheet:Cells( 1, 1 ):Value    := dWrite

   dRead       := oSheet:Cells( 1, 1 ):Value
   msginfo( "Written : Read" + CRLF +  ;
            "DTOC " + DTOC( dWrite ) + " : " + DTOC( dRead ) + CRLF + ;
            "TTOC " + TTOC( dWrite ) + " : " + TTOC( dRead ) + CRLF + ;
            "TTOS " + TTOS( dWrite ) + " : " + TTOS( dRead ), ;
            If( dWrite == dRead, "EQUAL", "NOT EQUAL" ) )

   oBook:Close()

return nil

The equality comparison returns false. In earlier versions this was working perfectly.

I noticed this when I was rebuilding a large project. All those modules which depended or date comparisons are going haywire. An easy workaround to compare DTOC instead of dates can be recommended, but it is not practically possible to search through a large software and replace.

Has anyone noticed this problem and any news of fixing this bug ?
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: XHarbour TOleAuto Dates Bug
Posted: Mon Mar 30, 2009 08:38 AM

I have now downloaded latest version ( $Id: win32ole.prg,v 1.170 2008/12/22 22:09:45 likewolf Exp $ ) from http://www.xharbour.org and linked.

Now the date comparisons are working perfectly.

The problem seems to be in the XHarbour version provided along with FWH.

Regards



G. N. Rao.

Hyderabad, India
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: XHarbour TOleAuto Dates Bug
Posted: Mon Mar 30, 2009 09:05 AM
Can it be the following fix (from xHarbour CVS changelog)?

2008-10-02 20:00 UTC+0100 Jose F. Gimenez <jfgimenez/at/wanadoo.es>
* source/rtl/win32ole.prg
! TOleAuto was retrieving date-only values incorrectly


EMG
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: XHarbour TOleAuto Dates Bug
Posted: Mon Mar 30, 2009 09:14 AM

>
Can it be the following fix (from xHarbour CVS changelog)?
>
That must have been the fix.
FWH may need to release a new updated build of XHarbour

Regards



G. N. Rao.

Hyderabad, India
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: XHarbour TOleAuto Dates Bug
Posted: Mon Mar 30, 2009 12:35 PM

I have noticed the date comparison as well with SQL datetime fields . I have had to convert the date values to ctod(dtoc()) in order to compare dates. I don't know when this happend in xHarbour .. but I am using build 1.1.0 rev 6195

Rick Lipkin

Continue the discussion