I use SQL server 2008 R2
I want to make a simple one select
that GETDATE()
shows a specific date format without a 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
12/1
i tried this:
SELECT (MONTH(GETDATE())/ Day(GetDate())) as Fecha
the result is :
Date
0
For SQL Server 2012+, it's best to use
FORMAT
:If not, you can use:
Or also
With this last code, the result would be
01/12
You can use the CONCAT function:
All the best
It worked for me like this:
If you do it with a specific field and table:
This can help you
You need to first convert what it shows you to text in order to concatenate the results.
For that you have to use the function
CONVERT
. Applied to what you want it would be:You could try CAST or CONVERT of datetime with a Date Style, convert it to a 5-character varchar, so that it takes the first 5 characters of dd/mm/yyyy, that is, it would take dd/mm.
Example of day/month
month/day example