Reading DateTime values from Access mdb

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

hstijnen
Junior Boarder
Junior Boarder
Posts: 32
Joined: 11.04.2012, 08:49

Reading DateTime values from Access mdb

Postby hstijnen » 25.09.2012, 15:54

Hi,
I've an Access database with a table aTable and columns SysTime (Date/Time) and Value (float). I create the following query:

Query->SQL->Text = "SELECT SysTime, Value FROM aTable WHERE SysTime >= :from AND SysTime <= :to"
// fill in pars
Query->Params->FindParam("from")->AsDateTime = FromTime;
Query->Params->FindParam("to")->AsDateTime = ToTime;
// open
Query->Open();

That runs all OK, giving the correct number of records and the correct Value's.
double pvalue = Query->FindField("Value")->AsFloat; // correct pvalue

HOWEVER, the date/time values give only the Date part:
double tfloat = Query->FindField("SysTime")->AsFloat; // gives only integer
TDateTime Datetime = Query->FindField("SysTime")->AsDateTime; // gives only Date part

How to retrieve the full Date/Time values from Access Mdb?

Thanks in advance

Regards, Henk

User avatar
EgonHugeist
Zeos Dev Team
Zeos Dev Team
Posts: 1701
Joined: 31.03.2011, 22:38

Postby EgonHugeist » 28.09.2012, 01:02

hstijnen,

No idea why it fails, Henk. With a MsSQL Server it works fince, right? Can't test it by my selves..
King regards, Michael

You want to help? viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image

hstijnen
Junior Boarder
Junior Boarder
Posts: 32
Joined: 11.04.2012, 08:49

Postby hstijnen » 28.09.2012, 09:20

With MsSQL server indeed OK.

I use way around:
SELECT SysTime, Waarde, year(SysTime) as j1, month(SysTime) as m1, day(SysTime) as d1, hour(SysTime) as h1, minute(SysTime) as n1, second(SysTime) as s1

and then
int j1 = Query->FindField("j1")->AsInteger;
int m1 = Query->FindField("m1")->AsInteger;
int d1 = Query->FindField("d1")->AsInteger;
int h1 = Query->FindField("h1")->AsInteger;
int n1 = Query->FindField("n1")->AsInteger;
int s1 = Query->FindField("s1")->AsInteger;
TDateTime dt1 = EncodeDateTime(j1, m1, d1, h1, n1, s1, 0);

Then it's OK.

User avatar
EgonHugeist
Zeos Dev Team
Zeos Dev Team
Posts: 1701
Joined: 31.03.2011, 22:38

Postby EgonHugeist » 28.09.2012, 14:14

hstijnen,

dirty workaround ): but seems to work, Henk. I have no testbase to check the issue. It might also be possible that Access assignes the values wrong to the Variants. Does it work with a ADOConnection?
King regards, Michael

You want to help? viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image


Return to “ZeosLib 7.0 Beta Forum”

Who is online

Users browsing this forum: No registered users and 1 guest