Hello,
DateTime fields are only shown and edited as Date fields in ADO.
Thank you.
FWH 20.04, Harbour 3.2.0 dev (r1909261630) y BCC 7.40
Hello,
DateTime fields are only shown and edited as Date fields in ADO.
Thank you.
Up!
Up please!
Up! Thank you.
Any help, please?
Has been fixed in new Fwh?
Please wait a little.
Are you using MySql or Microsoft SQL?
Access and Mysql. Thank you.
Any clue please?
Thank you.
#include "fivewin.ch"
#include "adodef.ch"
#define USE_ADO
static oCn
static cTable := "testdatetime"
//----------------------------------------------------------------------------//
function Main()
local cSql, oRs
SET DATE ITALIAN
SET CENTURY ON
SET TIME FORMAT TO "HH:MM:SS"
oCn := FW_DemoDB( "ADO" ) // or connec to your MySql server
TRY
oCn:Execute( "DROP TABLE testdatetime" )
CATCH
END
TEXT INTO cSql
CREATE TABLE `testdatetime` (
`ID` INT AUTO_INCREMENT PRIMARY KEY,
`NAME` VARCHAR ( 20 ),
`DTIME` DATETIME
)
ENDTEXT
oCn:Execute( cSql )
cSql := "INSERT INTO testdatetime ( NAME, DTIME ) VALUES ( 'One', '2018-10-20' )"
oCn:Execute( cSql )
oRs := FW_OpenRecordSet( oCn, "select * from testdatetime" )
? oRs:Fields( "dtime" ):Type, ;
oRs:Fields( "dtime" ):Value, ;
ValType( oRs:Fields( "dtime" ):Value )
MakeDialog( oRs )
oRs:Close()
oCn:Execute( "DROP TABLE testdatetime" )
oCn:Close()
return nil
//----------------------------------------------------------------------------//
static function MakeDialog( oRs )
local oDlg
DEFINE DIALOG oDlg SIZE 250,150 PIXEL TRUEPIXEL
@ 20,60 GET oRs:Fields( "name" ):Value SIZE 150,24 PIXEL OF oDlg
@ 50,60 GET oRs:Fields( "dtime" ):Value SIZE 150,24 PIXEL OF oDlg
@ 90,60 BUTTON "OK" SIZE 100,40 PIXEL OF oDlg ACTION oDlg:End()
ACTIVATE DIALOG oDlg CENTERED
return nil
//----------------------------------------------------------------------------// ? oRs:Fields( "dtime" ):Type, ;
oRs:Fields( "dtime" ):Value, ;
ValType( oRs:Fields( "dtime" ):Value )@ r,c GET oRs:Fields( "dtime" ):Value
Thank you very much.
I can´t compile because in FW 14.14 there is not FW_DemoDB( "ADO" ) function, but I already have ordered the FTDN renew.
I asume I will have the same behaviour that you: Harbour returns the value as Date not DateTime. This is the behaviour I get in my software, either with Access or MYSQL.
Is this a Harbour bug?
Thank you again. All the best,
Yes, with latest FWH I get the same wrong behaviour.
Thank you.
Extract from whatsnew.txt FWH 19.10
In many databases like MSAccess, MSSQL, Oracle only DateTime field type is
avaiable for storing both simple dates and date-time values. Whether a
particular field is to be treated as Date or DateTime field mostly depends
on the usage. Accordingly FWH libraries treat fields containing pure Date
values (without any time-part) as Date fields and fields containing DateTime
values are treated as DateTime fields. While this approach works satisfactorily
in most cases, there could be exceptions and the programmer needs to have
the facility to override the default behavior.
Databases like MYSQL,POSTGRE provide separate field types for Date and DateTime
and the above approach is not relevant in these cases.
Now from this version:
In cases of databases MYSQL,POSTGRE field types as reported by ADO are used
irrespective of the values stored.
In case of other databases, the existing default behaviour will continue and
the programmer can override by:
oCol:cDataType := .T. // xbrowse
oRec:FieldType( "fieldname", "T" ) // DataRow and TRecSet

SET TIME FORMAT TO "HH:MM:SS"