Solved

to_date between oracle and teradata using oracle gateway

Posted on 2010-11-19
4
1,786 Views
Last Modified: 2013-11-11
this column "Date_Pay" is CHAR(10) at teradata WH and it looks like this
'2010-10-18'


when I try this sql filter
AND cast(cl."Date_Pay" as date) BETWEEN TO_DATE ('2010/01/01',
                                                       'yyyy/mm/dd')
                                          AND  TO_DATE ('2010/01/02',
                                                        'yyyy/mm/dd')

I get error msg ORA-01861

literal does not match format string

Cause: Literals in the input must be the same length as literals in the format string (with the exception of leading whitespace). If the "FX" modifier has been toggled on, the literal must match exactly, with no extra whitespace.

Action: Correct the format string to match the literal.
0
Comment
Question by:it-rex
  • 2
  • 2
4 Comments
 
LVL 11

Expert Comment

by:Akenathon
ID: 34174006
Instead of CAST, try using TO_DATE on the field.

Try this: AND cast(cl."Date_Pay" as date) < sysdate

...and you'll see the to_dates you already have are not the cause of the problem.
0
 
LVL 11

Author Comment

by:it-rex
ID: 34174021
how can I use a between clasue,here?
0
 
LVL 11

Accepted Solution

by:
Akenathon earned 500 total points
ID: 34174040
You CAN use the between. That part is not wrong. The part which is wrong is the portion before the between

You need to convert your character field to a date. That is not done using CAST, it is done using to_date in this fashion:


AND TO_DATE(cl."Date_Pay", 'yyyy/mm/dd') BETWEEN TO_DATE ('2010/01/01',
                                                       'yyyy/mm/dd')
                                          AND  TO_DATE ('2010/01/02',
                                                        'yyyy/mm/dd')
0
 
LVL 11

Author Closing Comment

by:it-rex
ID: 34174080
thanks
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Oracle PL/SQL syntax 4 52
Parametric query in oracle 6 37
T-SQL Convert to PL/SQL 23 61
PL/SQL LOOP CURSOR 3 40
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and theā€¦
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now