SQLTeam.com | Weblogs | Forums

Add day name to date field

Hello,
having this query:

select pubDate from Books
....
08/07/2020

How can I obtain also the day name, possibly with language chooice?
Like

Mer 08/07/2020
Wed 08/07/2020

(Ita First, us second).

Thank you.

Luis

declare @d date = getdate()

select DateName(weekday, @d), GetDate()

hi

please see if this helps :slight_smile:

please click arrow to the left for drop create data script
----------------------
-- create table 

create Table temp
(
date123 date 
)



go 

---------------------------
-- insert into data 

insert into temp select '1/5/2020'
go
select 
     DATENAME ( dw , date123 )  
   , date123 
from 
    temp 

image

I have to get 1 only field, and the day has to have only 3 chars.

For example:

Mer 08/07/2020

Should I use CONCAT or similar?

L.

monthandweekdayshortname1-2

hi

hope this helps

select 
     Format(date123,'ddd')  + ' ' + cast( date123 as nvarchar)
   , date123 
from 
    temp 
go 

image

1 Like

That's perfect. Thank you Harish.

Luigi