以下命令给我当前月(3月)的简短形式.
SELECT left(datename(month, getdate()), 3)
Run Code Online (Sandbox Code Playgroud)
但我需要上个月2月.
我的意思是,无论何时我运行这个命令都会给我上个月的名字.
什么是sql命令?
Fra*_*ois 11
假设您使用的是T-SQL:
SELECT left(datename(month, dateadd(month,-1,getdate())), 3)
Run Code Online (Sandbox Code Playgroud)
http://msdn.microsoft.com/fr-fr/library/ms186819.aspx