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
Use the Best way
where
V_MONTH_NUM
is the month numberUse this statement to convert Month numeric value to Month name.
Starting with SQL Server 2012, you can use FORMAT and DATEFROMPARTS to solve this problem.
If you want a three-letter month:
If you really want to, you can create a function for this:
you can get the date like this. eg:- Users table
you can get the monthname like this
output
This one worked for me:
From a post above from @leoinfo and @Valentino Vranken. Just did a quick select and it works.