I figured this out, the release of NHibernate.dll that I had in my project did not had implemented the 'date' function in MsSql2000Dialect I looked through ILDASM.exe disassembler and saw that the 'date' was not implemented.
I donwloaded the source https://nhcontrib.svn.sourceforge.net/svnroot/nhibernate/trunk/nhibernate/src/ the latest in the trunk, and the 'date was implemented' you can see it here https://nhcontrib.svn.sourceforge.net/svnroot/nhibernate/trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs compiled it through visual studio not through NANT and copied the dll's Nhibernate.dll, castle, linfu, etc.. and it worked perfectly, I wonder if the source that I compiled is ready to be used in a project or not? I got it from the trunk folder as you can see it above. The best way is to extend the class Nhibernate.Dialect.MsSql2000Dialect and add the 'date' function like this guy did, http://www.codewrecks.com/blog/index.php/2010/06/04/nhibernate-hql-query-with-only-date-part-of-a-datetimevalue/ but the problem is when I try to use my customized Dialect in hibernate.cfg.xml it throws an Exception InnerException: NHibernate.HibernateException Message=”Could not instantiate dialect class Entities.DbTools.Sql2008Dialect” Source=”NHibernate” StackTrace: at NHibernate.Dialect.Dialect.InstantiateDialect(String dialectName) at NHibernate.Dialect.Dialect.GetDialect(IDictionary`2 props) at NHibernate.Cfg.Configuration.AddValidatedDocument(NamedXmlDocument doc) InnerException: System.TypeLoadException Message=”Could not load type Entities.DbTools.Sql2008Dialect. Possible cause: no assembly name specified.” Source=”NHibernate” TypeName=”" StackTrace: at NHibernate.Util.ReflectHelper.TypeFromAssembly(AssemblyQualifiedTypeName name, Boolean throwOnError) at NHibernate.Util.ReflectHelper.ClassForName(String name) at NHibernate.Dialect.Dialect.InstantiateDialect(String dialectName) InnerException Can you help? Visar On Jun 6, 12:35 pm, Visar Uruqi <visar.ur...@gmail.com> wrote: > Hi > > I have a problem with HQL, the date function is not working, it is > throwing the exception below: > I'm using a simple query to get only the date from the DateTime field: > select date(t.Data) from Trajtimi t where t.Pacienti.ID = 3 > > I'm using "NHibernate.Dialect.MsSql2000Dialect" I've tried with > MsSql2008Dialect and also MsSql2005Dialect it's the same. > > I've looked also at source of > "NHibernate.Dialect.MsSql2000Dialect"https://nhcontrib.svn.sourceforge.net/svnroot/nhibernate/trunk/nhiber... > > I saw there the line, > RegisterFunction("date", new SQLFunctionTemplate(NHibernateUtil.Date, > "dateadd(dd, 0, datediff(dd, 0, ?1))")); > > I think the date function is implemented I tried the funcion in sql > management studio > "dateadd(dd, 0, datediff(dd, 0, someDateTime))" and it is striping the > time very well, but Nhibernate its not, at least for me. > > I don't know where I'm wrong, if you could guide me... > > P.S. The same thing in SQLite is working perfect. > > Visar > > NHibernate.QueryException was unhandled > Message="No data type for node: MethodNode ( ( date ( exprList > ( trajtimi0_.Data trajtimi0_.ID Data ) ) ) [select date(t.Data) as > dteRegj from Entities.Trajtimi t where t.Pacienti.ID = 3]" > Source="NHibernate" > QueryString="select date(t.Data) from Entities.Trajtimi t where > t.Pacienti.ID = 3" > StackTrace: > at > NHibernate.Hql.Ast.ANTLR.Tree.SelectClause.InitializeExplicitSelectClause(F > romClause > fromClause) > at > NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.UseSelectClause(IASTNode select) > at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.ProcessQuery(IASTNode > select, IASTNode query) > at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.unionedQuery() > at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.query() > at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.selectStatement() > at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.statement() > at NHibernate.Hql.Ast.ANTLR.HqlSqlTranslator.Translate() > at > NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.Analyze(HqlParseEngine > parser, String collectionRole) > at > NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.DoCompile(IDictionary`2 > replacements, Boolean shallow, String collectionRole) > at > NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.Compile(IDictionary`2 > replacements, Boolean shallow) > at NHibernate.Engine.Query.HQLQueryPlan..ctor(String hql, > String collectionRole, Boolean shallow, IDictionary`2 enabledFilters, > ISessionFactoryImplementor factory) > at NHibernate.Engine.Query.HQLQueryPlan..ctor(String hql, > Boolean shallow, IDictionary`2 enabledFilters, > ISessionFactoryImplementor factory) > at > NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(String > queryString, Boolean shallow, IDictionary`2 enabledFilters) > at NHibernate.Impl.AbstractSessionImpl.GetHQLQueryPlan(String > query, Boolean shallow) > at NHibernate.Impl.AbstractSessionImpl.CreateQuery(String > queryString) -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to nhus...@googlegroups.com. To unsubscribe from this group, send email to nhusers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.