Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 127275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:27:03+00:00 2026-05-11T05:27:03+00:00

When I add this to my where clause: DueDate <= getDate() AND DueDate IS

  • 0

When I add this to my where clause:

DueDate <= getDate() AND DueDate IS NOT null 

I get a nice little failure that says: Could not create child: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.Data.EvaluateException: The expression contains undefined function call getDate().

Any idea what I’m doing wrong?


Update Code in use:

private string getFilter(int mode) {     String filter = '';     if ((ALL_WORK_ORDERS & mode) == 0) {         if ((mode & OUTSTANDING_WORK_ORDERS) == OUTSTANDING_WORK_ORDERS) {             filter += 'DueDate <= getDate() AND DueDate IS NOT null OR';         }         if ((mode & COMPLETED_WORK_ORDERS) == COMPLETED_WORK_ORDERS) {             filter += ' FinishedDate IS NOT  null';         }     }      filter = filter.Trim();     if (filter.EndsWith('OR')) {         filter = filter.Remove(filter.Length - 2);     }      return filter; } 

And it is getting used here:

tblWorkOrderBindingSource.Filter = getFilter(mode); 

In the table, DueDate is type datetime.

Side note: I can run

SELECT [ID]       ,[WorkDesc]       ,[DueDate]   FROM [RentalEase].[dbo].[tblWorkOrder] WHERE [DueDate] <= getDate() AND [DueDate] IS NOT null 

in the MS SQL Server Management Studio Express without a problem.


Final Solution

    private string getFilter(int mode) {         String filter = '';         if ((ALL_WORK_ORDERS & mode) == 0) {             if ((mode & OUTSTANDING_WORK_ORDERS) == OUTSTANDING_WORK_ORDERS) {                 filter += 'DueDate <= #' + DateTime.Now.ToShortDateString() + '# AND DueDate IS NOT null  AND FinishedDate IS null OR';             }             if ((mode & COMPLETED_WORK_ORDERS) == COMPLETED_WORK_ORDERS) {                 filter += ' FinishedDate IS NOT null';             }         }          filter = filter.Trim();         if (filter.EndsWith('OR')) {             filter = filter.Remove(filter.Length - 2);         }          return filter;     } 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T05:27:03+00:00Added an answer on May 11, 2026 at 5:27 am

    The exception is pretty clear on what is wrong here. You are specifying a method, getdate, which can’t be used in a filter expression. See the documentation on the Expression property on the DataColumn class for what is valid and what is not:

    http://msdn.microsoft.com/en-us/library/system.data.datacolumn.expression.aspx

    That being said, instead of getdate, you need to concatenate the date into the filter (call the static Now property on the DateTime structure to get the current date). The link above will show you how to format dates properly (you can’t just do it as indicated in Kelly’s answer, although that answer is most of the way there).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a linq statement that I want to add an additional where clause
I'm triying to make a function that add a 'where' clause to a query
I was 'forced' to add myLocalVar = null; statement into finally clause just before
I'm trying to add a character limit clause to this white list regex approach
Is it possible to add another where clause on this, or do I need
I add this class to library/My/Validate/PasswordConfirmation.php <?php require_once 'Zend/Validate/Abstract.php'; class My_Validate_PasswordConfirmation extends Zend_Validate_Abstract {
I add this code in my activity public boolean onKeyDown(int keyCode, KeyEvent event) {
I add this tag to my asp.net page (aspx): <obout:Calendar runat=server ShowTimeSelector=true DateFormat=MM/dd/yyyy hh:mm:ss
i add this script to my page it is a poll contain a button
When I add this code to my Android 2.1 Java app, it fails: db=SQLiteDatabase.openOrCreateDatabase(Locations,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.