Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Trouble with SqlDataSource.FilterExpression: undefined function call DATEADD()

Posted on 2007-10-21
7
Medium Priority
?
2,506 Views
Last Modified: 2013-11-07
Hi Experts,

I have trouble with an filterexpression, always throwing this error:

Exception Details: System.Data.EvaluateException: The expression contains undefined function call DATEADD().

Whats wrong here? Am I not allowed to use sql-functions?

 args =   "Date > DATEADD(Month,"+ (int)-1 +" , GETDATE()))";
SqlDataSource1.FilterExpression = args;

thanks for your help in advance
regards
0
Comment
Question by:arthrex
  • 3
  • 3
7 Comments
 
LVL 11

Accepted Solution

by:
cmhunty earned 2000 total points
ID: 20118709
Nope, it's a string style filter only. You'll have to evaluate the  date and then pass it in as a string to the filterexpression
0
 
LVL 20

Expert Comment

by:Gawai
ID: 20118721
first you print
args =   "Date > DATEADD(Month,"+ (int)-1 +" , GETDATE()))";
Response.Write args
see what is the out put
0
 

Author Comment

by:arthrex
ID: 20118774
thank you both!!

cmhunty:

but how can I pass it in the correct dateformat then?
the clients have another format then the server.

gawai:
when I print it, it sais this:
"(Datum > DATEADD(Month, -1 , GETDATE()))"

thanks!
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 11

Expert Comment

by:cmhunty
ID: 20118869
Build the string like:

args = "Date > " & Now.AddMonths(Int() - 1)

where the date you're comparing with is built up in your code. My example is in VB.NET but I would think C# is very similar!
0
 

Author Comment

by:arthrex
ID: 20118924
thanks a lot.
but my problem is , that I have the wrong format when doing like that.
the clients have different formats like here german:
"(Date >21.09.2007 21:04:30)"
the server needs us-dateformat
so, how to convert?
0
 
LVL 11

Assisted Solution

by:cmhunty
cmhunty earned 2000 total points
ID: 20119009
This article should help you: http://www.dotnetspider.com/kb/Article276.aspx

So it'd be something like Now.AddMonths(Int() - 1).ToString("MM/dd/YYYY HH:mm:ss")
0
 

Author Comment

by:arthrex
ID: 20119199
thank a lot! thats it
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
Suggested Courses

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question