Home » SQL & PL/SQL » SQL & PL/SQL » Date (merged 2) 10g
Date (merged 2) 10g [message #411829] Tue, 07 July 2009 01:25 Go to next message
Messages: 43
Registered: December 2007
Location: CHENNAI
I have table with char data type.I have to subtract that from current date.
  create table test(Hdate varchar2(11));

  insert into test values('01-jun-2009');
  insert into test values('20-jun-2009');
  select *
    from test
   where round(sysdate - to_date(hdate,'dd-mon-yyyy')) >= 20 
  select *
    from test
    where trunc(sysdate) - to_date(hdate,'dd-mon-yyyy')>=20
kindly let me know for performance reason which query will be better.  

Thanks in advance

Re: Date (merged 2) 10g [message #411843 is a reply to message #411829] Tue, 07 July 2009 02:33 Go to previous messageGo to next message
Michel Cadot
Messages: 63923
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
It is meaningless and irrelevant to compare the performances of 2 queries that do not return the same result.

Re: Date (merged 2) 10g [message #411854 is a reply to message #411829] Tue, 07 July 2009 02:53 Go to previous message
Messages: 2818
Registered: May 2007
Location: Scotland
Senior Member
It is also very foolish to store dates as characters.
Previous Topic: unique constraint violation for two columns.. very confusing!
Next Topic: Deleting duplicate records.
Goto Forum:

Current Time: Tue Oct 25 12:56:48 CDT 2016

Total time taken to generate the page: 0.13816 seconds