I have months stored in SQL Server as 1,2,3,4,...12. I would like to display them as January,February etc. Is there a function in SQL Server like MonthName(1) = January? I am trying to avoid a CASE statement, if possible.
相关问题
- SQL join to get the cartesian product of 2 columns
- sql execution latency when assign to a variable
- Difference between Types.INTEGER and Types.NULL in
- What is the best way to cache a table from a (SQL)
- php PDO::FETCH_ASSOC doesnt detect select after ba
You can use the inbuilt
CONVERT
functionThis will display first 3 characters of month (JAN,FEB etc..)
Use this statement
this will convert the month number to month full string
Just subtract the current month from today's date, then add back your month number. Then use the datename function to give the full name all in 1 line.
To convert month number to month name, try the below
OR