user2362008 user2362008 - 5 months ago 14
SQL Question

How to get my required date format?

how to get this format (jun-2016) from saledate (20160624)

only shown the first 3 character of month name, my saledate is nvarchar datatype in tblSale
Thanks in advance

Answer

Simple Try this one

    DECLARE @SaleDate NVARCHAR(20) = '20160624'

    SELECT  SUBSTRING(DATENAME(MONTH,@SaleDate),1,3) + '-' + CONVERT(NVARCHAR(4),YEAR(@SaleDate))
Comments