Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

SQL Server - How to Get Only Month and Year From Date

Mar 12, 2014
Introduction:

Here I will explain how to get only month and year from date in
sql server or extract only month and year from date time field in sql server.
Description:

To get only month and year from date in sql server we need to write the query like this


SELECT CONVERT(CHAR(4), yourdatecolumn, 100) + CONVERT(CHAR(4), yourdatecolumn, 120)FROM yourtablename
Example


SELECT CONVERT(CHAR(4), getdate(), 100) + CONVERT(CHAR(4), getdate(), 120)
Once we run above query we will get output like as shown below

Output



If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

2 comments :

Anonymous said...

good morning sir
please send me notes, example of normalization,Acid property,how to get data from database in gridviews



Thanks

Anonymous said...

Hi,

We can use following query to get Month & Year in SQL

SELECT DATENAME(MONTH, GETDATE()) + ' ' + DATENAME(YEAR, GETDATE())

Give your Valuable Comments

Other Related Posts

© 2010-2012 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.