sql - How do we select data based on month and year in oracle query -


i have did research , found can done in msql

select * sales month(selldate) = 3 , year(selldate) = 2017 

but when tried oracle , returns me

ora-00904: "year": invalid identifier 

is there way call data based on month , year in oracle query ?

solved

thank , have came out solution

this how did .. :)

select * sales to_char(sell,'mm')='09' , to_char(sell,'yyyy')='2018'; 

you can use extract month , year date. example

select extract(year                current_date),        extract(month                current_date) dual; 

it generate result below.

enter image description here

so query posted in question can re-written below.

select * sales extract(month               selldate) = 3   , extract(year               selldate) = 2017; 

you can check demo here


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -