Querying an Oracle Date field using a string in NHibernate HQL

北城以北 提交于 2019-12-08 08:07:57

问题


I'm trying to query a .NET DateTime property and compare it with a date string like so:

SELECT cat FROM mydll.cats AS cat
WHERE cat.BirthDay > '1999-02-20'

When I'm trying to search by a date string (without the SetDate function) The query won't run saying I canno't compare a String to a Date.

Is there a way or a certain format I can use to compare my date with a simple string (Maybe something like the ToDate function in Oracle SQL..)
*I need to separate the HQL string from the NHibernate engine because of design issues

Thanks a lot [=


回答1:


The to_date function is mapped in the Oracle dialect, so:

SELECT cat FROM mydll.cats AS cat
WHERE cat.BirthDay > to_date('1999-02-20', 'yyyy-mm-dd')


来源:https://stackoverflow.com/questions/5132624/querying-an-oracle-date-field-using-a-string-in-nhibernate-hql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!