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

3 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())

Anonymous said...

how to know the year month and day from date of birth like 1986-08-10

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 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.