如果日期为10/16/2015,则datetime列为"2015-10-16 10:09:19.443"
如何在SQL Server中仅显示月份和年份为"10月15日"?
如果您使用SQL Server 2012或以后,您可以使用该Format()功能:
Declare @Date DateTime = '10/16/2015'
Select Format(@Date, N'MMM-yy')
Run Code Online (Sandbox Code Playgroud)
结果:
Oct-15
Run Code Online (Sandbox Code Playgroud)
编辑 - 根据@ lad2025的评论,如有必要,您可能还需要添加en-US语言环境:
Declare @Date DateTime = '10/16/2015'
Select Format(@Date, N'MMM-yy', 'en-US')
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1975 次 |
| 最近记录: |