Big problem with Access DateTimeFields

The alpha/beta tester's forum for ZeosLib 7.0.x series

Report problems concerning our Delphi 2009+ version and new Zeoslib 7.0 features here.

This is a forum that will be removed once the 7.X version goes into stable!!

Moderators: gto, EgonHugeist, olehs

glk70
Fresh Boarder
Fresh Boarder
Posts: 19
Joined: 08.03.2010, 17:58

Big problem with Access DateTimeFields

Postby glk70 » 07.05.2010, 16:10

I'm using a MSaccess database thorugh ADO interface via Zeosib

Executing a query with DastTime fields I always get only the date (integer) portion of the field.
I've followed the problem as far as I could and I've seend that the field type returned is a STdate, which is converted into a TDate.
TDate and TDateTime are just the same type in Delphi, yet the contet of the field is always an integer. S only the date portion of the field is returned.

I obviously need the time portion also.
Looks like the ADO provider is returning only the date portion of the field.

Any suggestion ?

seawolf
Zeos Dev Team *
Zeos Dev Team *
Posts: 385
Joined: 04.06.2008, 19:50
Contact:

Postby seawolf » 08.05.2010, 20:05

Looks like ADO activeX does not export DateTime fields.
So you coluld change, on ..\src\dbc\ZdbcAdoutils.pas

adDate : Result := stDate;

to

adDate : Result := stString;

So a datetime field is a String you can convert. The "problem" could be how that data is formatted.

glk70
Fresh Boarder
Fresh Boarder
Posts: 19
Joined: 08.03.2010, 17:58

Postby glk70 » 12.05.2010, 08:47

changing the field tipe in convertion doesn't solve the problem

The real problem is : when accessing DataTime fields date is truncated, so only the integer (days) part of the datetime field is transfered to the application, the hours are lost.

at this point changing the coding of the field (tdateTime = Single, or String) doesn't change the fact that the decimals (hours) part of the field are already lost.

at this point the application will always show 00.00 in the hour fields on the form.

I changed the connector and tried to use DBGO ADO connector.
Using this connector I can read DateTime fields with hours and days.
obviously I cannot use zeos with this connector and I had to implement a new interface between this set of the components and my application

So I think it is a problem of interface with the ActiveX/Com component of the m$ ole libray.
Somehow (I don't actually know neither how nor why) when accessing the query zeos declares or forces dateTime fields to Date, and consequently all data are truncated.

workaround : convert all fields to floating point. Delphi handles dates as single floating point values.
Once floating point is saved correctly to DB it can be converted to String dateTime format in any moment.
Obviously this is not possible if working on a living project with running databases and with other applications sharing access to them.

a patch is required for this.
If I'll have more information on the problem I'll share on this forum

Regards

seawolf
Zeos Dev Team *
Zeos Dev Team *
Posts: 385
Joined: 04.06.2008, 19:50
Contact:

Postby seawolf » 12.05.2010, 09:37

Reading here it looks like you need to declare that field in a different way, and using Access > 98

glk70
Fresh Boarder
Fresh Boarder
Posts: 19
Joined: 08.03.2010, 17:58

Postby glk70 » 12.05.2010, 11:16

the fields in access cannot be declared in that way
Field Types in Access are
Text
Memo
Numeric
Date/Time
Currency
Counter (i.e. long integer with autoincrement)
Boolean
Ole Object
HypertextLink ( ! )

What is presented in the article you are citing is what I tried to explain previuosly.
Somewhere and somehow Zeos is declaring date fields in the query as
adDate 7 Date
instead of
adDBTimeStamp 135 DateTime (Access 97 (ODBC))
Otherwise a declaring datetime fields as
adSingle 4 Single Real
would be suitable.

but looks like that using adDate is actually truncating the field value

Using DBGO I get DateTime fields as ftDateTime, even if the field holds only date value (i.e. an integer)
So I think it is a problem of how ZEOS declares or handles DateTime fields.

KDeveloper2
Fresh Boarder
Fresh Boarder
Posts: 14
Joined: 12.01.2010, 08:41

Postby KDeveloper2 » 15.07.2010, 10:24

Hi,
any news here?

i had the same problem with Delphi 2010.
i connect to Access with zeos, and the Date/Time Fields
are only available as Date Fields.


when i change ZDbcAdoUtils

Code: Select all

function ConvertAdoToSqlType(FieldType: SmallInt): TZSQLType;
begin
  case FieldType of
  ...
    adDate : Result := stTimestamp;
  ...


then i will displayed correctly in runtime, but not in designtime
Last edited by KDeveloper2 on 15.07.2010, 11:38, edited 1 time in total.

glk70
Fresh Boarder
Fresh Boarder
Posts: 19
Joined: 08.03.2010, 17:58

no news about date/time Fields

Postby glk70 » 15.07.2010, 11:22

Unfortunately No News.

as far as I could debug the problem there is something worng with the interface with ADO.
but I could not manage to lock down tot the problem.

It's likely a bit mismatch in field definition. So ADO returns only date fields because it is instructed in doing so by Zeos. But it is only a suspect.

KDeveloper2
Fresh Boarder
Fresh Boarder
Posts: 14
Joined: 12.01.2010, 08:41

Postby KDeveloper2 » 15.07.2010, 12:13

I think there is also another problem with access,
because there is only Date/Time, no Date and no Time and Delphi 2010 need the exact field definition.

I think you have to save your time value in a seperate string field.

glk70
Fresh Boarder
Fresh Boarder
Posts: 19
Joined: 08.03.2010, 17:58

Date/Time fields

Postby glk70 » 15.07.2010, 15:32

Access saves Date/Time , Date and Time values in the same fieldType.
I've not a clear detail how it can recognize the three different styles

What I knwo for sure is that

01-01-1980 15:38
is different from
15:38

but other db Interfaces (for example DBGO ) holds the date/teim , date and time values correctly

So I have to say there is something wrong in Zeos

Saving date and time values in two separate fields is a workaround.
Anyway be aware that I tried this

INSERTO INTO someTable ( timeField ) VALUES ( "15:38" )
SELECT timeField FROM someTable

and I got 0 ( zero ) !
So be carefull chosing the correct field type when saving times.

cañones
Fresh Boarder
Fresh Boarder
Posts: 1
Joined: 23.08.2011, 17:50

Re: Big problem with Access DateTimeFields

Postby cañones » 23.08.2011, 18:00

glk70 wrote:I'm using a MSaccess database thorugh ADO interface via Zeosib

Executing a query with DastTime fields I always get only the date (integer) portion of the field.
I've followed the problem as far as I could and I've seend that the field type returned is a STdate, which is converted into a TDate.
TDate and TDateTime are just the same type in Delphi, yet the contet of the field is always an integer. S only the date portion of the field is returned.

I obviously need the time portion also.
Looks like the ADO provider is returning only the date portion of the field.

Any suggestion ?


hello, could you solve this problem, I feel the same.
work with delphi 7 and Zeos 6.6.5.
Sorry for my english

glk70
Fresh Boarder
Fresh Boarder
Posts: 19
Joined: 08.03.2010, 17:58

Re: Big problem with Access DateTimeFields

Postby glk70 » 24.08.2011, 15:43

cañones wrote:
hello, could you solve this problem, I feel the same.
work with delphi 7 and Zeos 6.6.5.
Sorry for my english


Sorry I cannot use Delphi7 because it is incompatible with Windows7.
The only version I can use is Delphi2010.
And Zeos Lib seems to be unable to handle correctly the datetime conversion for MsAccess


Return to “ZeosLib 7.0 Beta Forum”

Who is online

Users browsing this forum: No registered users and 1 guest