Convert Date Format into Dd/Mmm/Yyyy Format in SQL Server

How to get a particular date format ('dd-MMM-yyyy') in SELECT query SQL Server 2008 R2

Try this:

Declare @dt NVARCHAR(20)

Select
@dt = REPLACE(CONVERT(CHAR(15), SalesDate, 106),' ',' - ')
FROM SalesTable

Convert Date format into DD/MMM/YYYY format in SQL Server

I'm not sure there is an exact match for the format you want. But you can get close with convert() and style 106. Then, replace the spaces:

SELECT replace(convert(NVARCHAR, getdate(), 106), ' ', '/')

How to convert a string to a date from dd mmm yyyy format in SQL Server

You can use the following using CONVERT:

SELECT CONVERT(DATE, string, 106)

-- example
SELECT CONVERT(DATE, '07 Nov 2014', 106) -- 2014-11-07

You can find a list with all date and time styles (3rd parameter - 106) on the microsoft docs. You can also find a working demo on SQL Fiddle.

date format convert into varchar dd-mmm-yy format in sql server 2012

Try with the below query..

DECLARE @testdate DATETIME
SELECT @testdate = '2016-08-23'

SELECT LEFT (CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(@testdate)-1),@testdate),113),6)
+' to '+LEFT(CONVERT(VARCHAR(25),DATEADD(dd,-(DAY(DATEADD(mm,1,@testdate))),
DATEADD(mm,1,@testdate)),113),11) AS Date_Value


Related Topics



Leave a reply



Submit