473,394 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

problem in to_date function

hi
i have a table c_table with two columns
no,
date
it contains records

no n_date
1 10-AUG-03
2 21-AUG-03

when we issue
select * from c_table where n_date='10-AUG-03';
it will successfully return the record

but when we give
select * from c_table where n_date='21-AUG-03';

it will not return the record

after using to_date function like
select * from c_table where to_date(n_date,'DD/MM/YY')='21/08/03';

it will successfully return the records
but the main problem is that
when we have table that contains 50,000,00 records
**and then using to_date function then it will slow down the performance

how we can solve the.
Jul 19 '05 #1
2 25276
Nic
Hi,
for part of your question related to the performance, i think you could modify your query to get

select * from c_table where n_date = to_date('21/08/03','DD/MM/YY');

so the to_date function get call only once, of course if you have store the date data with differents time you still will need to
call the trunc function.

select * from c_table where trunc(n_date) = to_date('21/08/03','DD/MM/YY');

"KULJEET" <ku***********@hotmail.com> wrote in message news:fe**************************@posting.google.c om...
hi
i have a table c_table with two columns
no,
date
it contains records

no n_date
1 10-AUG-03
2 21-AUG-03

when we issue
select * from c_table where n_date='10-AUG-03';
it will successfully return the record

but when we give
select * from c_table where n_date='21-AUG-03';

it will not return the record

after using to_date function like
select * from c_table where to_date(n_date,'DD/MM/YY')='21/08/03';

it will successfully return the records
but the main problem is that
when we have table that contains 50,000,00 records
**and then using to_date function then it will slow down the performance

how we can solve the.

Jul 19 '05 #2
ku***********@hotmail.com (KULJEET) wrote in message news:<fe**************************@posting.google. com>...
[]

the main problem is that in
when i issue
---------------------
select to TO_CHAR(N_DATE,'DD/MM/YY HH24:MI') from c_table
the it will return
10/08/03 00:00
10/08/03 00:00
10/08/03 00:00
21/08/03 16:21
----------------
so
10/08/03 date it will store time as 00:00
10/08/03 00:00

but in 21/08/03 it will store time as 16:21

21/08/03 16:21
BUT IT WILL NOT WORK
select * from c_table where n_date = to_date('21/08/03','DD/MM/YY');
BUT THIS WILL WORK
select * from c_table where trunc(C_date) = to_date('21/08/03','DD/MM/YY');
CAN TRUNC FUNCTION SLOW DOWN THE PERFORMANCE????


Unless you have created a matching function-based index, any function
on a column will prevent the use of indices and thus Possibly affect
performance.

The questions you need to ask yourself are:
A:Is the time portion of the date really needed?
B:Is the performance unacceptable using the various function based
solutions?

If the answer to A is NO, then update the data to truncate (or round)
the time portion away, then all your dates will be at midnight and
will match appropriately and use possible indices as the Optimizer
sees fit.

If the answer to A is YES and the answer to B is NO, then using the
trunc() doesn't hurt you case.

If A is YES and B is YES, then consider either: creating a function
based index OR adding a search date column (another column that
contains the truncated date values used only for searching and
indexing).

finally here's an untested query that should still use possible
indices and gets by the trunc():

SELECT * FROM c_table WHERE n_date BETWEEN
to_date('21/08/03','DD/MM/YY') AND to_date('21/08/03','DD/MM/YY')+1
;

(NOTE the plus one).

HTH
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Damjan | last post by:
I'm using Python 2.4, cx_Oracle-4.1 on Linux with Oracle instant client 10.1.0.3. This is the sql string: SQL = """insert into D.D_NOTIFY values (:CARDREF, :BANKKEY, :OK1, :OK2 \ :DEBTEUR,...
1
by: Amin Schoeib | last post by:
Hi, Can somebody tell me why this query don't work when I use to_date Instead of to_char By using to_char: select to_char(last_day(cast(current_date - interval '1 month' as...
2
by: gimme_this_gimme_that | last post by:
Assuming data is being stored in a DB2 TIMESTAMP what is the equivalent of Oracle's to_date function : to_date('03/04/2005','MM/DD/YYYY') It's OK if MM/DD/YYYY is the only supported format....
5
by: gane kol | last post by:
Hi when i try to use to_date function in C# codebehind, i am getting to_date doesnt exist in class or namespace error. i am trying to use something similar to INSERT INTO OracleTypesTable...
0
by: ina | last post by:
Good Morning, My Name is Ina and I have a problem if a test in the xsl file, I am newbie in XML transformation :) So this is a piece of my code xml. Contracts nodes I have fund contract...
0
by: rysulliv | last post by:
I am trying to run the query bellow, and I get a mismatched datatype error for the two "sum" computation columns. I thought that using "null" in the corresponding columns would eliminate the...
1
by: gillian3114 | last post by:
why this sum function won't work ? eg Sum(personal) lblPersonal.Caption it wont retrieve the sum value of personal Dim cn6 As New ADODB.Connection Dim strCNString4 As String Dim rs6 As New...
4
by: hydroraven | last post by:
Hello all, I am trying to use the TO_DATE function to convert a string to a date so that I can perform periodic maintenance on a table based upon the date. Here is the SQL statement. ...
2
by: KULJEET | last post by:
hi i have a table c_table with two columns no, date it contains records no n_date 1 10-AUG-03 2 21-AUG-03
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.