...

View Full Version : [ oracle ]find part of date



tom123
08-15-2006, 11:55 AM
I nedd to check the year part of date in following format:

DD-MMM-YYYY

I have


$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

MRMAN
08-15-2006, 12:05 PM
try this.



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);

tom123
08-15-2006, 02:01 PM
That year function dosnt seem to be working
Enetering this in oracle manually


SELECT * FROM t_mou_eco_product
WHERE YEAR(EPR_FROM) = "2006";

I get oracle error:

ORA-00904: "2006": invalid identifier

arnyinc
08-15-2006, 03:24 PM
SELECT * FROM t_mou_eco_product
WHERE to_char(EPR_FROM, 'YYYY') = '2006';

MaheshRamesh
07-27-2012, 09:37 AM
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:)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum