Get only month and day using SELECT in SQL server

Use SQL server 2008 R2

I want to make a simple select that by means of a GETDATE() shows a specific date format with no Year:

Day / month

This select gives me the values but in separate columns

SELECT MONTH(GETDATE()), Day(GetDate())

I need to do it but in this example format: day 1 month December

Date
1/12

Tried this:

SELECT (MONTH(GETDATE())/ Day(GetDate())) as Fecha

The result is:

Date
0

 2
Author: Levi Arista, 2016-10-26

7 answers

For SQL Server 2012+, it is best to use FORMAT:

SELECT FORMAT(GETDATE(),'dd/MM') Fecha;

If not, you can use:

SELECT DATENAME(DAY,GETDATE()) + '/' + CONVERT(VARCHAR(2),MONTH(GETDATE())) Fecha
;

Or also

SELECT CONVERT(VARCHAR(5),GETDATE(),103) Fecha;

With this last Code, the result would be 01/12

 6
Author: Lamak, 2016-10-26 14:31:18

You can use the CONCAT function:

SELECT CONCAT(MONTH(GETDATE()), '/', Day(GetDate())) as Fecha

A greeting

 2
Author: Slashhh, 2016-10-26 14:29:57

Worked a lot for me this way:

SELECT FORMAT(GETDATE(),'yyyy-MM-dd') as fecha;

If you do it with a field and table in specified:

SELECT FORMAT(nombre_campo,'yyyy-MM-dd') as fecha FROM nombre_tabla;
 1
Author: C47, 2018-04-13 20:23:16

This can serve you

SELECT CAST(Day(GetDate()) AS VARCHAR(10) ) +'/'+ CAST(MONTH(GETDATE()) AS VARCHAR(10)) as Fecha
 0
Author: sioesi, 2016-10-26 14:30:51

You need to convert what it shows to text first in order to concatenate the results.

For that you need to use the function CONVERT. Applied to what you want would be:

SELECT (CONVERT(varchar(3),DAY(GETDATE()))+'/'+ CONVERT(varchar(3),MONTH(GetDate()))) as Fecha
 0
Author: Jose Javier Segura, 2016-10-26 14:33:02

You could try with cast or CONVERT of datetime with a Date Style, convert it to a varchar of 5 characters, so that you take the first 5 characters of dd / mm / yyyy IE take dd / MM.

Day / month example

SELECT CONVERT(VARCHAR(5),GETDATE(),103) AS FECHA 

Month / day example

SELECT CONVERT(VARCHAR(5),GETDATE(),101) AS FECHA
 0
Author: JessMad, 2016-10-26 14:34:17
SET LANGUAGE Spanish
SELECT CONCAT('día ', DAY(GETDATE()), ' mes ', DATENAME(month, GETDATE()))
 -1
Author: Alonso Fallas, 2016-10-26 14:36:16