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

  • Home
  • SEARCH
  • 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 873103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:52:55+00:00 2026-05-15T10:52:55+00:00

Dear SQL Gurus from Stack Overflow: Environment: Oracle I’m trying to understand why I

  • 0

Dear SQL Gurus from Stack Overflow:

Environment: Oracle

I’m trying to understand why I can’t do a to_date selection on a table column that contains strings. Note tableZ with a column of name Value in the example below contains a bunch of strings, some of which are the correct format, for example 6/20/2010 00:00:00.

tableZ

| Value              |
| __________________ |
| 6/21/2010 00:00:00 |
| Somestring         |
| Some Other strings |
| 6/21/2010 00:00:00 |
| 6/22/2010 00:00:00 |

The following works

SELECT To_Date(c.Value, 'MM/DD/YYYY HH24:MI:SS') somedate 
          FROM tableX a, tableY b, tableZ c 
         WHERE Lower(a.name) = 'somedate' 
           AND a.id = b.other_id 
           AND b.id = c.new_id

This returns something like (which is good):

| somedate            |
| __________________  |
| 21.06.2010 00:00:00 |
| 21.06.2010 00:00:00 |
| 22.06.2010 00:00:00 |

The following does not work

SELECT To_Date(c.Value, 'MM/DD/YYYY HH24:MI:SS') somedate 
          FROM properties$aud a, template_properties$aud b, consumable_properties$aud c 
         WHERE Lower(a.name) = 'somedate' 
           AND a.id = b.property_id 
           AND b.id = c.template_property_id 
           AND To_Date(c.Value, 'MM/DD/YYYY HH24:MI:SS') IS NOT NULL

Comes back with:

ORA-01861: literal does not match format string

What am I missing here? Just a quick note:

 ...
AND b.id = c.template_property_id 
AND To_Date(c.Value, 'DD.MM.YYYY HH24:MI:SS') IS NOT NULL

doesn’t work either.

Thanks!!

Goal to be able to do date BETWEEN queries on c.value in order to select date ranges.

  • 1 1 Answer
  • 1 View
  • 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. Editorial Team
    Editorial Team
    2026-05-15T10:52:55+00:00Added an answer on May 15, 2026 at 10:52 am

    The order that Oracle evaluates the conditions found in the where clause is not fixed. That is to say that it can choose to evaluate the condition containing TO_DATE before the other criteria, in which case the query will fail. To prevent that, add the ordered_predicates hint to your query, but be aware that this may require additional manual tuning to improve performance.

    SELECT /*+ ordered_predicates */
                   To_Date(c.Value, 'MM/DD/YYYY HH24:MI:SS') somedate 
              FROM properties$aud a, 
                   template_properties$aud b, 
                   consumable_properties$aud c 
             WHERE Lower(a.name) = 'somedate' 
               AND a.id = b.property_id 
               AND b.id = c.template_property_id 
               AND To_Date(c.Value, 'MM/DD/YYYY HH24:MI:SS') IS NOT NULL
    

    Apparently ordered_predicates is deprecated starting with 10g. In that case, I think your only option is to use a sub-query in such a way that optimizer is forced to evaluate it first (i.e. it can’t combine the queries). The easiest way to do this is to put rownum in the where statement of the inner query.

    SELECT To_Date(c.Value, 'MM/DD/YYYY HH24:MI:SS') somedate 
      FROM (SELECT value 
              FROM properties$aud a, 
                   template_properties$aud b, 
                   consumable_properties$aud c 
             WHERE Lower(a.name) = 'somedate' 
               AND a.id = b.property_id 
               AND b.id = c.template_property_id
               AND rownum > 0) 
     WHERE To_Date(c.Value, 'MM/DD/YYYY HH24:MI:SS') IS NOT NULL
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Dear Stack Overflow Community, I have a question regarding how to incorporate a WHERE
Dear All, I have another issue. I have in the SQL table Employees. This
Dear StackOverflow community, I have a dataset from my university projects I am trying
Dear All, please help me since I'm newbie in SQL Server. I have a
Dear Friends from Stackoverflow, Please help me with a problem that i'm having when
Dear all devexpress winform gurus:) My way is simple. First, i create a bindinglist:
Dear experts, I was trying to align an paragraph to the middle of an
Dear experts, I was trying to dynamically generate DOM elements using JS. I read
Dear LINQ or linq2sql experts, can you help me to solve this case? I
Dear Stackoverflowers, I am trying to build a simple web application in ASP.NET where

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.