aspx Tutorial

NET Articles,jQuery demo, asp.net with jQuery, online tutorial,Jquery, SilverLight, Javascript, asp.net,JSON, MVC,.NET Articles,demo, Web Services,
Advertise Here

Toolbar

Get our toolbar!

Advertize



Posted by Aamir Hasan   on Sunday, March 27, 2011 Total Views:  

In this example, you will see how to get month name from input data. I have used build in function named DATETIME. DATETIME function used two parameters. DATETIME function will always return a string. I have created a virtual table and inserted some dummy records to display it.

Syntax

DATENAME ( datepart , date )

Example

DECLARE @PATIENT TABLE

    (

      ID BIGINT IDENTITY ,

      FULLNAME VARCHAR(50) ,

      GENDER CHAR ,

      BIRTHDAY DATE

    )

INSERT  INTO @PATIENT

VALUES  ( 'AAMIR HASAN', 'M', '2000-11-11' ),

        ( 'AWAIS AHMED', 'M', '2006-10-01' ),

        ( 'HINA KHAN', 'F', '2005-12-02' ),

        ( 'SABA KHAN', 'F', '2004-09-04' ),

        ( 'DIVAN', 'M', '2003-03-08' ),

        ( 'AAMIR', 'M', '2002-01-11' )

SELECT  ID ,

        FULLNAME ,

        GENDER = CASE GENDER

                   WHEN 'M' THEN 'MALE'

                   WHEN 'F' THEN 'FEMALE'

                 END ,

        [BORTHDAY MONTH NAME] = UPPER(DATENAME(MONTH, BIRTHDAY))

FROM    @PATIENT

Output

Download

How to get Month Name in T-SQL.sql (682.00 bytes)

Protected by Copyscape Online Plagiarism Tool

Comments (2) -

Delmar Michieli
Delmar Michieli United States
7/1/2015 7:08:53 AM #

I'll immediately clutch your rss feed as I can not to find your email subscription hyperlink or newsletter service. Do you have any? Kindly permit me recognize so that I may just subscribe. Thanks.|

Vickey Cahue
Vickey Cahue United States
7/8/2015 3:35:57 AM #

I have been browsing online more than 4 hours today, yet I never found any interesting article like yours. It's pretty worth enough for me. Personally, if all web owners and bloggers made good content as you did, the internet will be much more useful than ever before.|

Cody Christoph
Cody Christoph United States
7/9/2015 6:38:30 AM #

I have been browsing online more than three hours today, yet I never found any interesting article like yours. It's pretty worth enough for me. In my view, if all website owners and bloggers made good content as you did, the internet will be a lot more useful than ever before.|

Hollie Alguire
Hollie Alguire United States
7/21/2015 3:39:16 AM #

Some really   prize  posts  on this  internet site ,  saved to fav.

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

Advertizement 1
Advertizement 2
Advertizement 3
Advertizement 4
Advertizement 5