New Posts New Posts RSS Feed: Query Search on Date Field
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Query Search on Date Field

 Post Reply Post Reply
Author
mbevins1 View Drop Down
Newbie
Newbie


Joined: 16-Jan-2009
Posts: 27
Post Options Post Options   Quote mbevins1 Quote  Post ReplyReply Direct Link To This Post Topic: Query Search on Date Field
    Posted: 22-Jul-2009 at 7:37am
I am having a hard time trying to figure out how to search on a date only field.  How do I create my where clause? 

Where schdate = Convert.ToDateTime(dateParameters[0].InputedValue)

No matter what I pass, I get a lot of different errors saying invalid query syntax.

My execution looks something like this:

var query = new PassthruEsqlQuery(entityType, sql);

ObservableCollection<EntityBase> dataSource = new ObservableCollection<EntityBase>(Globals.EntityManager.ExecuteQuery(query).Cast<EntityBase>().ToList());

Back to Top
mbevins1 View Drop Down
Newbie
Newbie


Joined: 16-Jan-2009
Posts: 27
Post Options Post Options   Quote mbevins1 Quote  Post ReplyReply Direct Link To This Post Posted: 22-Jul-2009 at 11:42am
Appears in order to get this to work, you have to use QueryParameters rather than just building out your where clause.
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 22-Jul-2009 at 1:33pm
You should be able to construct a query string containing the date - it's just that Entity SQL has a very non-intuitive syntax for date fields.  Here's some info from the MSDN - http://msdn.microsoft.com/en-us/library/bb399176.aspx, and here's a link to a similar question here - http://www.ideablade.com/forum/forum_posts.asp?TID=806
 
 
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down