# Issue with the datatype of Date and Datetime returned from sql query were different

**URL:** https://talk.remobjects.com/t/issue-with-the-datatype-of-date-and-datetime-returned-from-sql-query-were-different/32176
**Category:** Pascal Script
**Created:** [September 12, 2025, 4:01pm UTC](https://talk.remobjects.com/t/issue-with-the-datatype-of-date-and-datetime-returned-from-sql-query-were-different/32176 "2025-09-12T16:01:40Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![spriya](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/s/839c29/32.png) [@spriya](https://talk.remobjects.com/u/spriya)
#### Post date: [September 12, 2025, 4:01pm UTC](https://talk.remobjects.com/t/issue-with-the-datatype-of-date-and-datetime-returned-from-sql-query-were-different/32176/1 "2025-09-12T16:01:40Z")

</div>

Hi,

In Delphi 11, when the datetime type field was attempted to be returned as a date from a SQL query, it was returned as “ftwidestring.” The value was null as a result, and the variable could not be used in other queries to fetch the data.

To further understand the problem, a sample test case and document are included.  
[NullExcptn.7z](https://talk.remobjects.com/uploads/short-url/1xx8fcPEOZyqhbNggqBgYBvkccX.7z) (15.4 KB)

[SS.docx](https://talk.remobjects.com/uploads/short-url/1GvdscFsCJ9pWn1tZqnrwurU7OM.docx) (192.9 KB)

---

<div class="post-metadata">

### Author: ![EvgenyK](https://talk.remobjects.com/user_avatar/talk.remobjects.com/evgenyk/32/16_2.png) [@EvgenyK](https://talk.remobjects.com/u/EvgenyK)
#### Post date: [September 15, 2025, 8:09am UTC](https://talk.remobjects.com/t/issue-with-the-datatype-of-date-and-datetime-returned-from-sql-query-were-different/32176/2 "2025-09-15T08:09:36Z")

</div>

Hi,

if you do the same SQL (`select cast(dt_col1 as date) from table`) w/o PS, what datatype will be returned by DevartSQLConnection for `Fields[0]`?

I’ve suspicion that this is Devart issue and it may return ftWideString for every `cast`.

---

<div class="post-metadata">

### Author: ![spriya](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/s/839c29/32.png) [@spriya](https://talk.remobjects.com/u/spriya)
#### Post date: [September 15, 2025, 11:34am UTC](https://talk.remobjects.com/t/issue-with-the-datatype-of-date-and-datetime-returned-from-sql-query-were-different/32176/3 "2025-09-15T11:34:43Z")

</div>

Hi,

It’s an issue from Devart side. Thanks and sorry .
