Sohail xIN3N
Sohail xIN3N

Reputation: 3041

SQL Server - Change Date Format

I want to format my date column in SQL Server like this Wed, 23 from given date format 4/23/2014.

Exactly like this in image below

Is there any way to do this...?

SQL Server version is 2008

Upvotes: 3

Views: 462

Answers (3)

Vignesh Kumar A
Vignesh Kumar A

Reputation: 28403

Try like this

SELECT LEFT(DATENAME(dw, GETDATE()), 3) + ' , ' + CAST(Day(GetDate()) AS Varchar(10))

Fiddle Demo

Query would be like this

SELECT mydate,LEFT(DATENAME(dw, mydate), 3) + ' , ' + CAST(Day(mydate) AS Varchar(10)) As Date 
From tbl

SQL FIDDLE

O/P

MYDATE        DATE
2014-04-21    Mon ,21
2014-04-22    Tue ,22
2014-04-23    Wed ,23
2014-04-24    Thu ,24

Upvotes: 3

Lali
Lali

Reputation: 2866

select Substring(DATENAME(WEEKDAY, getdate()), 0, 4)+' '+ DATENAME(dd, getdate())

Upvotes: 1

vhadalgi
vhadalgi

Reputation: 7189

Try this!

declare @a table(a date)
insert into @a values('4/21/2014'),('5/21/2014'),('6/21/2014')

select left(DATENAME(dw,a),3)+','+convert(varchar(10),datepart(day,a)) from @a

DEMO

Upvotes: 1

Related Questions