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
convey05
Messages: 43
Registered: December 2007
Location: CHENNAI
Member
Hi,
I have table with char data type.I have to subtract that from current date.
Eg:
  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: 68737
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
It is meaningless and irrelevant to compare the performances of 2 queries that do not return the same result.

Regards
Michel
Re: Date (merged 2) 10g [message #411854 is a reply to message #411829] Tue, 07 July 2009 02:53 Go to previous message
pablolee
Messages: 2882
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: Fri Feb 14 09:59:28 CST 2025