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: DATE_FORMAT with CreateQuery
PostPosted: Thu Aug 14, 2008 5:33 am 
Beginner
Beginner

Joined: Tue May 29, 2007 3:14 am
Posts: 28
I have got a problem to create a select with a formated DateTime.

Trial 1:
dim sql as string = "SELECT AVG(x.Short) , AVG(x.Month) , Date_Format(x.DateTime, '%H') as Time from History x GROUP BY Time "
Dim list As IList = Session.CreateQuery(sql).List

Trial 2:
dim sql as string = "SELECT AVG(x.Short) , AVG(x.Month) , Date_Format(x.DateTime, '%H') from History x GROUP BY Date_Format(x.DateTime, '%H') "
Dim list As IList = Session.CreateQuery(sql).List


Error:
Both times I get the same error.
undefined alias or unknown mapping: Date_Format [SELECT AVG(x.Short) , AVG(x.Month) , Date_Format(x.DateTime, '%H') as Time from History x GROUP BY Time ]


<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="History, History" table="history" >
<id name="ID" column="ID" type="Int32" unsaved-value="0">
<generator class="identity" />
</id>
<many-to-one name="History" column="ID_RefHistory " class="History, History" fetch="join"/>
<property name="DateTime" column="DateTime" type="DateTime" />
<property name="Short" column="Short" type="Int32" length="4" />
<property name="Month" column="Month" type="Int32" length="4" />
</class>
</hibernate-mapping>

Does anybody can tell me what I have to do, if I want to group all values to get a hourly result?

[/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.