Go Back   CodingForums.com > :: Server side development > MySQL > Other Databases

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-15-2006, 11:55 AM   PM User | #1
tom123
Regular Coder

 
Join Date: Apr 2005
Location: Ireland
Posts: 122
Thanks: 4
Thanked 0 Times in 0 Posts
tom123 is an unknown quantity at this point
[ oracle ]find part of date

I nedd to check the year part of date in following format:

DD-MMM-YYYY

I have

Code:
$year_query = "2006";

qq(SELECT epr_code,
               epr_name,
               epr_from,       
               epr_type
    FROM t_mou_eco_product
    WHERE epr_from LIKE '$year_query\_%' ESCAPE '\'
    AND epr_active = 1
    ORDER BY epr_code);
This isnt working. Can someone please help?

Thanks in advance

Last edited by guelphdad; 08-20-2006 at 12:44 AM..
tom123 is offline   Reply With Quote
Old 08-15-2006, 12:05 PM   PM User | #2
MRMAN
Regular Coder

 
Join Date: Jan 2006
Location: Preston, Lancashire, England
Posts: 285
Thanks: 0
Thanked 0 Times in 0 Posts
MRMAN is an unknown quantity at this point
try this.
Code:
qq(SELECT epr_code,
               epr_name,
               epr_from,       
               epr_type
    FROM t_mou_eco_product
    WHERE YEAR(epr_from) = '$year_query'
    AND epr_active = 1
    ORDER BY epr_code);
MRMAN is offline   Reply With Quote
Old 08-15-2006, 02:01 PM   PM User | #3
tom123
Regular Coder

 
Join Date: Apr 2005
Location: Ireland
Posts: 122
Thanks: 4
Thanked 0 Times in 0 Posts
tom123 is an unknown quantity at this point
That year function dosnt seem to be working
Enetering this in oracle manually

Code:
SELECT * FROM t_mou_eco_product
WHERE YEAR(EPR_FROM) = "2006";
I get oracle error:

ORA-00904: "2006": invalid identifier

Last edited by tom123; 08-15-2006 at 02:18 PM..
tom123 is offline   Reply With Quote
Old 08-15-2006, 03:24 PM   PM User | #4
arnyinc
Regular Coder

 
Join Date: Jan 2003
Posts: 867
Thanks: 4
Thanked 8 Times in 8 Posts
arnyinc is an unknown quantity at this point
SELECT * FROM t_mou_eco_product
WHERE to_char(EPR_FROM, 'YYYY') = '2006';
arnyinc is offline   Reply With Quote
Old 07-27-2012, 09:37 AM   PM User | #5
MaheshRamesh
New to the CF scene

 
Join Date: Jul 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
MaheshRamesh is an unknown quantity at this point
Thumbs up Extract the "YEAR" from the date Column in Oracle

Please use the followg query to resolve the mentioned error:

SELECT * FROM <Table_Name>
WHERE EXTRACT(YEAR FROM TO_DATE(TRUNC(Column_Name), 'DD-MON-RR')) = '2010';

It is working fine
MaheshRamesh is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:22 PM.


Advertisement
Log in to turn off these ads.