是否还有其他方法可以在Sql中获取月份的shorcut(仅限3个字符) [英] Is there any other way to get shorcut for Month in Sql(only 3 character)
本文介绍了是否还有其他方法可以在Sql中获取月份的shorcut(仅限3个字符)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想把月份当作
Jan
2月
5月
只有3个字符。
- 我尝试了什么:
选择 SUBSTRING(datename(month,getdate()), 1 , 3 )
有点建议是否有其他功能/方法可以解决问题。
解决方案
< blockquote>怎么样 -
选择 left (datename(month,GetDATE()), 3 )
>
您还可以使用CONVERT ( VARCHAR ( 3 ),GETDATE())
为'mmm dd yyyy hh:mi [AM | PM]'是日期转换的默认格式,VARCHAR(3)只返回前3个字符
你还应该使用:
<无线电通信/>
选择转换(char(3),ColumnName,0)作为来自tableName的AliasName
从你的表中ColumnName和AliasNameFor重复名称
I want to get the month as
Jan
Feb
May
Only 3 characters.
--What i have tried :
select SUBSTRING(datename(month,getdate()),1,3)
Kindy suggest is there any other function/way which can solve the problem.
解决方案
How about this -
select left(datename(month, GetDATE()),3)
You could also useCONVERT(VARCHAR(3),GETDATE())
as 'mmm dd yyyy hh:mi[AM|PM]' is the default format for date conversion, and VARCHAR(3) will just return the first 3 characters
You Should Also Use:
select convert(char(3), ColumnName, 0) as AliasName from tableName
Above "ColumnName" From Your Table And "AliasName" For Duplicate Name
这篇关于是否还有其他方法可以在Sql中获取月份的shorcut(仅限3个字符)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文