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

Chinese Restaurant Supplies
Chinese Restaurant Supplies United States
10/15/2013 9:28:54 PM #

Hi there, simply become aware of your blog through Google, and found that it's truly informative. I'm gonna be careful for brussels. I will appreciate should you continue this in future. Lots of people will be benefited out of your writing. Cheers!|

Mandy Dee Twitter
Mandy Dee Twitter United States
2/9/2014 10:12:29 PM #

Am I permitted to discuss this on twitter?

Josefa Rodabaugh
Josefa Rodabaugh United States
6/3/2014 7:09:31 AM #

You should take part in a contest for one of the best blogs on the web. I will recommend this site! More For xxx video http://www.uxxx.me/

Quincy Panagis
Quincy Panagis United States
7/8/2014 11:56:21 AM #

I��m not certain where you're getting your info, but great topic. I needs to spend some time learning much more or understanding more. Thanks for great info I used to be looking for this information for my mission.

Aaron
Aaron United States
7/21/2014 10:21:14 PM #

There are actually numerous details like that to take into consideration. That may be a great level to bring up. I provide the thoughts above as general inspiration however clearly there are questions like the one you carry up where crucial thing shall be working in sincere good faith. I don?t know if greatest practices have emerged around things like that, however I'm positive that your job is clearly identified as a fair game. Each boys and girls feel the impact of only a second�s pleasure, for the rest of their lives.

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

Advertizement 1
Advertizement 2
Advertizement 3
Advertizement 4
Advertizement 5