Job Seekers   Employers
dbapool: Authors | Submissions | Contact Us
   Forgot password? | Sign up
  Home   Discussion Forum   Articles   Interview Questions   FAQs   Scripts   Rewards   Analyzer   White Papers   Blog   Certification   Downloads   Tools
 

Topic: SQL*Plus and PL/SQL >> pl/sql substr

Disclaimer: The purpose of all dbapool forums including OCP and Other Oracle Certification forums is to help each other with specific issues but not to share dump and copyrighted exam content, materials or intellectual property. You may review the entire Oracle Certification Program Candidate Agreement online Here.



  


 Title: pl/sql substr
 labyrinth248  Posted: May 06, 2008 11:13:29 AM

 Total Post: 1
 Joined: May, 2008






 Hey everyone.
I am using toad and I’m trying to grab just the last for digits of data in the column. The column is a NUMBER(8). Ex. the data that would show in this column would be ‘20080506’. I need to just grab the 0506 part of the data. So far this is what I have:

select distinct
, FC.rate_end_dt
from ft_revenue_charge_200801_T FC
where substr(fc.RATE_END_DT, 8, 4) BETWEEN 0501 and 0931

I need to grab the last four digits in the column between 0501 and 0931.
For some reason it is grabbing all dates…

Thanks Guys

 Mohammed Taj
Posted: May 06, 2008 12:31:25 PM  

 Total Post: 634
 Joined: Jul, 2007






 
then use SUBSTR in your select statement not in WHERE cluase.

select substr(col1,5) from tablename where col1 between starting_value and ending_value;

SQL> select * from d;

COL1
--------------------
20080501
20080502
20080503
20080504
20080505
20080506
20080507
20080508
20080509
20080510

10 rows selected.

SQL> select substr(col1,4) from d where col1 between '20080501' and '20080505';

SUBSTR(COL1,4)
-----------------
80501
80502
80503
80504
80505

 Time Zone: EDT

  




Forum Rules & Description


Who Can Read The Forum? Any registered user or guest
Who Can Post New Topics? Any registered user
Who Can Post Replies? Any registered user




 








Get FREE Magazines

Top 10 Forum User

  Mohammed Taj634
  Murtuja Khokhar587
  Jayanta Sur479
  Vigyan Kaushik385
  Ramesh Jois226
  neeraj sharma189
  snehalatha p166
  Gitesh Trivedi151
  Gopu Gopi146
  Kushal ratnaker136






oracle Mag



  About Us Advertise Terms of Use Privacy Newsletters Contact Us    

Home   Discussion Forum   FAQs  Articles  Jobs   Newsletters  Directory  Downloads 

Our Premium Sponsor
Confio Software