question

Bone12-2270 avatar image
0 Votes"
Bone12-2270 asked Viorel-1 answered

Show month as text

Hi,

I have a date time field (date_in) 2021-09-15 11:12:58.2220000 and I would like to pull out the month only. I have created a column month(date_in) as date_in_month but the output is 1-12.

Any idea how I can see this as Jan - Dec please instead?

sql-server-general
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Viorel-1 avatar image
0 Votes"
Viorel-1 answered

Check an example that uses FORMAT:

 declare @date_in as datetime = '2021-09-15 11:12:58.222'
    
 select @date_in, format(@date_in, 'MMM')



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.