views:

26

answers:

1

hi, I am using Castle ActiveRecord for my application. My problem is how to use a datetime string in HQL like this (without using parameters):

"from Contact c where c.DayOfBirth = '5/3/1988'"
+1  A: 

Try using YYYY-MM-DD format:

from Contact c where c.DayOfBirth = '1988-05-03'
Mauricio Scheffer
Thank you, Scheffer. I have tried: "from Contact c where c.DayOfBirth = 1988-05-03" and the query can execute without throw an exception, but it did not return any record.
Trần Quốc Bình
@Trần Quốc Bình: you probably want `where c.DayOfBirth between '1988-05-03' and '1988-05-04'`
Mauricio Scheffer
It still doesn't work.
Trần Quốc Bình
@Trần Quốc Bình: are you sure you have any records in the table with such DayOfBirth?
Mauricio Scheffer
@Trần Quốc Bình: Use a profiler (http://nhprof.com) or set the key `show_sql` in your app.config to true. Once you get a hold of the query Castle is executing you can take it from there.
Mike
Thanks Mike, but I can not find out the real query.
Trần Quốc Bình

related questions