Skip to page contentSkip to chat
ServiceNow support
    • Community
      Ask questions, give advice, and connect with fellow ServiceNow professionals.
      Developer
      Build, test, and deploy applications
      Documentation
      Find detailed information about ServiceNow products, apps, features, and releases.
      Impact
      Accelerate ROI and amplify your expertise.
      Learning
      Build skills with instructor-led and online training.
      Partner
      Grow your business with promotions, news, and marketing tools
      ServiceNow
      Learn about ServiceNow products & solutions.
      Store
      Download certified apps and integrations that complement ServiceNow.
      Support
      Manage your instances, access self-help, and get technical support.
ODBC driver does not return any results when the WHERE clause contains CURDATE() - Known Error
  • >
  • Knowledge Base
  • >
  • Known Error (Knowledge Base)
  • >
  • ODBC driver does not return any results when the WHERE clause contains CURDATE()
KB0547786

ODBC driver does not return any results when the WHERE clause contains CURDATE()


832 Views Last updated : Apr 7, 2024 public Copy Permalink
KB Summary by Now Assist

Description

CURDATE() yields a "null" in SOAP encoded query when used in a WHERE clause.

1.0.7.3 Driver: Returns 0 records because the encoded query is wrong.
1.0.5 Driver: Yields a NullPointerException.

Steps to Reproduce

Within iSQL:

1. Use CURDATE() on its own to see expected behavior.
ISQL> SELECT DATEADD('dd',-10,CURDATE());
DATEADD(dd, -10, CURDATE())

2. Use CURDATE() within a WHERE clause to see unexpected behavior.
ISQL> SELECT sys_id, number FROM incident WHERE (sys_created_on >= DATEADD('dd',-10,CURDATE())) AND sys_id = '8829085b0f4eb1004f2ff45be1050e5f';
sys_id number

Rows selected = 0

Workaround

Instead of using CURDATE() inside WHERE clauses, use the DATEADD function.

For example, for a query such as following:

SELECT number, sys_created_on FROM incident WHERE sys_created_on <= CURDATE()+10;

Use:

SELECT number, sys_created_on FROM incident WHERE sys_created_on <= DATEAD 
D('dd',+10,CURDATE()); 


Related Problem: PRB623553

Potentially Seen In

There is no data to report.

Fixed In

Geneva

The world works with ServiceNow.

Sign in for more! There's more content available only to authenticated users Sign in for more!
Did this KB article help you?
Did this KB article help you?

How would you rate your Now Support digital experience?

*

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

What can we improve? Please select all that apply.

What are we doing well? Please select all that apply.

Tell us more

*

Do you expect a response from this feedback?

  • Terms and conditions
  • Privacy statement
  • GDPR
  • Cookie policy
  • Cookie Preferences
  • © 2025 ServiceNow. All rights reserved.
We use cookies on this site to improve your browsing experience, analyze individualized usage and website traffic, tailor content to your preferences, and make your interactions with our website more meaningful. To learn more about the cookies we use and how you can change your preferences, please read our Cookie Policy and visit our Cookie Preference Manager. By clicking “Accept and Proceed,” closing this banner or continuing to browse this site, you consent to the use of cookies.