Click here to Skip to main content
15,881,380 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my table i have one field which contains the date, i want to take only month from that
is it possible?
similarly how can i take month from system date?
Posted

You can use the DATEPART function to get the month number or DATENAME function to get the month name.
SQL
select datepart(month,Mydate), datename(month,Mydate)

Source[^]

See Solution 2 for the oracle answer. (I didn't see that tag, sorry)
 
Share this answer
 
v2
Comments
RaisKazi 26-Sep-12 11:36am    
5ed. Its always a great fun to work with DATEPART, DATENAME and other Sql Server functions.!
Maciej Los 26-Sep-12 15:55pm    
Good work! +5
For SQL Server
SQL
SELECT MONTH(MyDateColunm) from MyTable;


To get System/Current Month.
SQL
SELECT MONTH(GETDATE());


For Oracle
SQL
select to_char(MyDateColunm, 'Month') from MyTable;

To get System/Current Month.
SQL
select to_char(sysdate, 'Month') from dual;
 
Share this answer
 
Comments
fjdiewornncalwe 26-Sep-12 11:30am    
+5. I didn't see the oracle tag.
RaisKazi 26-Sep-12 11:35am    
Thank you Marcus!.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900