如何将数字转换为月? [英] how to convert number to Month ?

查看:79
本文介绍了如何将数字转换为月?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



i希望将数字转换为月份

但不知道怎么办?

目前我有来自storedprocedure的输出< br $>


i want to convert number to month
but dont know how to do ?
currently i have this output from storedprocedure

Month
========
04
05
01
02
11
10



但我希望这个输出没有更改storedprocedure查询因为它在其他页面上使用所以无法更改sp。


but i want this output without changes storedprocedure query coz its used at other pages so cant change sp.

Month
=======
April
May
January
February
November
December





请给我一个解决方案

thanx



Please give me a solution
thanx

推荐答案

尝试将此查询合并到现有查询中,即月份即将到来。



此查询将月份转换为月份名称。



现在无需在代码隐藏页面上进行转换,无需代码。





Try to merge this query into your existing query where the month is coming.

This query will convert number of month to name of month.

Now there is no need to conversion on codebehind page, no code required.


Select DateName( month , DateAdd( month , @MonthNumber , -1 ) )


hi。

你可以使用枚举。

定义枚举:

hi .
you can use enum.
define enum:
public enum Month
        {
            April = 4,
            May = 5
        }



并将枚举值保存到数据库中然后如果要从月份中读取月份你的数据库

你可以使用反射或投射保存的值来枚举相应的值。

i希望这能帮到你


and save enum values into database then if you want to read month from your database
you can use Reflection or cast saved values to enum correspinding values.
i hope this help you


你好,



参考:



1)将月份数转换为SQL中的月份名称函数

2)在SQL Server中将月份编号转换为月份名称


这篇关于如何将数字转换为月?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆