Monday, May 13, 2013

Get month value from Date in SQL server

Get month value from Date in SQL server:

Sample:


select month(getdate()) as month_num, datename(month,getdate()) as month_name


month_num                 month_name


----------- ------------------------------

5                          May





select month(getdate()) as month_num , datename(month,'1-jan-2013') as month_name

month_num                    month_name


----------- ------------------------------

5                            January

0 comments:

Post a Comment