Print Page | Close Window

Date Problem in PassthruEsql Query

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=806
Printed Date: 13-Mar-2025 at 7:28am


Topic: Date Problem in PassthruEsql Query
Posted By: Dinesh
Subject: Date Problem in PassthruEsql Query
Date Posted: 14-May-2008 at 7:03am

Cosider the Following PassthruEsql Query

SELECT VALUE m from Members AS m WHERE (1=1) AND ( (0=1) or (m.SSN like '_Data_') or (m.MemberName.LastName like '_Data_') or (m.BirthDate = 7/23/1958 12:00:00 AM) or (m.Contact.Phone like '_Data_') )

When i run above PassthruEsqlQuery it gives following error :

IdeaBlade.EntityModel.v4.EntityServerException: The query syntax is not valid, near term '12', line 1, column 163. --->  System.Data.QueryException: The query syntax is not valid, near term '12', line 1, column 163.

When i remove m.birthdate part from PassthruEsqlQuery it works fine and gives me the result.

so pl. tell whats wrong with Date Part in above passthruESql Query.

Thanks




Replies:
Posted By: kimj
Date Posted: 14-May-2008 at 3:01pm
Since this is a pass through query, the syntax is validated by the Entity Framework and must meet EF eSQL requirements.  Date literals are a little tricky and need to be formatted something like this:
  Datetime 'yyyy-mm-dd hh:mm'
 
So, your birthdate clause should work if rewritten like this:
    (m.BirthDate = Datetime'1958-07-23 00:00')
 
Here's a link to some info on eSQL literal support:  http://msdn.microsoft.com/en-us/library/bb399176.aspx - http://msdn.microsoft.com/en-us/library/bb399176.aspx
 
 


Posted By: Dinesh
Date Posted: 14-May-2008 at 10:27pm

Thanks for your response... it works...

Thanks once again...




Print Page | Close Window