-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: How to cast/convert a datetime in an NHibernate query?
PostPosted: Tue Dec 23, 2008 10:54 am 
Newbie

Joined: Tue Jul 29, 2008 10:53 am
Posts: 11
I would like to execute with NHibernate a query like this:

Code:
select convert(varchar(10), PaymentDate, 105)
from order
group by convert(varchar(10), PaymentDate, 105)


This query returns all unique PaymentDates from the Order table in a shortdate format:

15-12-2008
16-12-2008
21-12-2008
...
...

I can execute native SQL with NHibernate, but I would like to do this with HQL or with a Criteria Query, something like this:

Code:
IQuery query = session.CreateQuery("select convert(varchar(10), o.PaymentDate, 105) from Order o group by convert(varchar(10), o.PaymentDate, 105)");


I don't know how to convert or cast a datetime with HQL, and I can't find it anywhere.

Does anyone know how to solve this with NHibernate?[/code]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.