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

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

Reading DateTime values from Access mdb

Post by hstijnen »

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 Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Post by EgonHugeist »

hstijnen,

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

You want to help? http://zeoslib.sourceforge.net/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

Post by hstijnen »

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 Project Manager
Zeos Project Manager
Posts: 1936
Joined: 31.03.2011, 22:38

Post by EgonHugeist »

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?
Best regards, Michael

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

Image
Locked