how to select top 2 row from emp table

  • Hi,

    Good afternoon

    I want to display date date format like dd-MMM-YYYY

    eg:-

    My Requirement like this...

    from Date is 27th April 2008 then i want diplay this from Dat like this format 27-Apr-2008

    i tried like this

    SELECT CONVERT( CHAR(6), fromDate, 106 )

    FROM EMP

    it gives out put like this :- 27 Apr 08

    but i want out format like this 27-Apr - 2008

    Plz hekp me to achive this

    Regds,

    Rclgoriparthi

  • That's an odd format - no default conversion for it.

    So, it takes some string manipulation:

    SELECT REPLACE(LEFT(CONVERT(VARCHAR,GETDATE(),13),11),' ','-')

  • SELECT REPLACE(CONVERT(CHAR(11), GETDATE(), 106), ' ', '-')


    N 56°04'39.16"
    E 12°55'05.25"

  • Please don't cross post.

    The Monthname function will get you the month name, you can use datepart to extract the others, and then concatenate the strings together (CASTing required for the numbers).

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply