Reputation: 2608
I have a EntityDataSource and I have to filter all items older 30 days.
my approach on my MSSQL database:
protected void EntityDataSource1_Selecting(object sender, EntityDataSourceSelectingEventArgs e)
{
EntityDataSource1.WhereParameters.Clear();
EntityDataSource1.Where = "DATEDIFF(day, GETDATE(), it.CreateDate) < 30" ;
}
gives the error: DATEDIFF cannot be resolved into a valid type or function
Upvotes: 0
Views: 539
Reputation: 6203
You need call SqlServer.DATEDIFF()
, use this:
EntityDataSource1.Where = "SqlServer.DATEDIFF(day, GETDATE(), it.CreateDate) < 30" ;
instead
EntityDataSource1.Where = "DATEDIFF(day, GETDATE(), it.CreateDate) < 30" ;
Here you find similar question but with DATEADD
function
Upvotes: 1