Skip to content Skip to sidebar Skip to footer

Oracle : Year Keyword Invalid

I have dates stored in the price_date column in one of my oracle tables. I need to filter records that belong to the year 2014 for e.g select * from MIS_PERMAL.MV_INDEX_PERFORMANCE

Solution 1:

Oracle doesn't have a year() function. You seem to have got that syntax from a different database (like MySQL).

You can use the extract() function instead:

select*from MIS_PERMAL.MV_INDEX_PERFORMANCE
where index_id =1045andEXTRACT(YEARfrom PRICE_DATE) =2014

Solution 2:

I up-voted Alex's answer, here is another method:

select * from MIS_PERMAL.MV_INDEX_PERFORMANCE 
where index_id = 1045andtrunc(PRICE_DATE, 'YYYY') = date '2014-01-01';

Post a Comment for "Oracle : Year Keyword Invalid"