I have to do a batch to send daily mails to the clients if is their birthday. I don't know how to get the day and month from database and compare with datetime.now. day and datetime.now.month . In the database I have one column date_naissance Date, and I have 2 fields to compare in my query. I don't know how to configure the xml file. I've tried 2 methods...but it didn't work.
First method:
Code:
BaseDataAccess bda = new BaseDataAccess();
ICriteria crit = bda.CreateCriteria(typeof(Client));
crit.Add(Expression.Eq("DataNM",DateTime.Now.Month));
crit.Add(Expression.Eq("DataNJ",DateTime.Now.Day));
return crit.List() as ArrayList();
The second method:
Code:
string str = "FROM client WHERE MONTH(date_naissance) = MONTH(NOW()) AND DAYOFMONTH(date_naissance) = DAYOFMONTH(NOW())";
IQuery qry= NHibernateHttpModule.CurrentSession.CreateQuery(str);
//I've tried this too...IQuery qry = bda.CreateQuery(str) as IQuery;
return qry.List() as ArrayList;
For the second method I have this message:
Quote:
in expected: <end-of-text> (possibly an invalid or unmapped class name was used in the query) [FROM client WHERE MONTH(date_naissance) = MONTH(NOW()) AND DAYOFMONTH(date_naissance) = DAYOFMONTH(NOW())]
I'm sure that the xml file it's not configured well but I don't know how to do it. Pls help...