|
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]
|