New Posts New Posts RSS Feed: Date Problem in PassthruEsql Query
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Date Problem in PassthruEsql Query

 Post Reply Post Reply
Author
Dinesh View Drop Down
Newbie
Newbie
Avatar

Joined: 18-Apr-2008
Location: United States
Posts: 4
Post Options Post Options   Quote Dinesh Quote  Post ReplyReply Direct Link To This Post Topic: Date Problem in PassthruEsql Query
    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

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: 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
 
 
Back to Top
Dinesh View Drop Down
Newbie
Newbie
Avatar

Joined: 18-Apr-2008
Location: United States
Posts: 4
Post Options Post Options   Quote Dinesh Quote  Post ReplyReply Direct Link To This Post Posted: 14-May-2008 at 10:27pm

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

Thanks once again...



Edited by Dinesh - 14-May-2008 at 10:36pm
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down