473,503 Members | 1,953 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 25280
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
3747
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
5659
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
18370
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
4593
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
911
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
1023
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
1095
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
10305
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
201
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
7205
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
7093
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7287
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,...
1
5021
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4685
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1519
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
397
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.