问题
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