Print Page | Close Window

Query Search on Date Field

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2009
Forum Discription: For .NET 3.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1384
Printed Date: 13-Sep-2025 at 11:25pm


Topic: Query Search on Date Field
Posted By: mbevins1
Subject: Query Search on Date Field
Date 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());




Replies:
Posted By: mbevins1
Date 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.


Posted By: kimj
Date 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 - 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 - http://www.ideablade.com/forum/forum_posts.asp?TID=806
 
 



Print Page | Close Window