Impossible to cast a Date into Datetime (DBF Uniprovider)

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
development
Posts: 2
Joined: Wed 10 Oct 2018 08:43

Impossible to cast a Date into Datetime (DBF Uniprovider)

Post by development » Wed 26 Dec 2018 15:35

Hi,

I am using DBF Uniprovider to read DBF database. I want to cast a Date field into a DateTime field to be able to read it using asDateTime function.

When I directly use the Date field without explicit conversion: works fine
SELECT a.date as newduedate FROM mytable a => ok (but it is not what I want)
When I explictly cast the Date field into DateTime : error "can't access to the field as DateTime"
SELECT CAST(a.date as datetime) as newduedate FROM mytable a => KO, not od DateTime type

I need to explicitly convert the field into DateTime because it will be the result of a CASE that I need to explicitly cast into DateTime for using asDateTime method.

If somebody can help me,

Thanks so much.

azyk
Devart Team
Posts: 1119
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: Impossible to cast a Date into Datetime (DBF Uniprovider)

Post by azyk » Fri 28 Dec 2018 11:54

In the latest release of UniDAC, we added a possibility to map fields to DateTime for TDBFUniprovider.
In order for the newduedate field from the specified SQL query to be mapped to DateTime, add the following mapping rule:

Code: Select all

  UniQuery.DataTypeMap.AddFieldNameRule('newduedate', ftDatetime);
  UniQuery.Open;
More details about Data Type Mapping in our online documentation: https://www.devart.com/unidac/docs/data ... apping.htm .

development
Posts: 2
Joined: Wed 10 Oct 2018 08:43

Re: Impossible to cast a Date into Datetime (DBF Uniprovider)

Post by development » Fri 28 Dec 2018 12:29

I have the last release of Unidac. I used the AddFieldNameRule method but it doesn't change anything.
newDueDate is not recognized as DateTime.

azyk
Devart Team
Posts: 1119
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: Impossible to cast a Date into Datetime (DBF Uniprovider)

Post by azyk » Fri 28 Dec 2018 13:50

We cannot reproduce this issue. Please compose a small test project for its demonstration. In the project, include all files of the mytable table (mytable.dbf + mytable.* memo and index files). Use the contact form at our website http://www.devart.com/company/contactform.html and send us the project.

Post Reply