Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
wsilage
Yak Posting Veteran
82 Posts |
Posted - 2013-07-10 : 08:56:41
|
Hi,I can get the name of the month by doing this...SELECTDatename(month,getdate()) as monthNameBut I am not able to get the previous Month? How can I do that I thought by putting -1 it would do that for me, but it doesn't.What other suggestions can you give me? Thanks! |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-07-10 : 08:59:31
|
SELECTDatename(month,DATEADD(mm,DATEDIFF(mm,0,getdate())-1,0)) as monthName------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-07-10 : 09:02:29
|
If you are on SQL 2012datename(month,eomonth(getdate(),-1)) |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2013-07-10 : 11:02:38
|
SELECTDatename(month,dateadd(month, -1, getdate())) as monthName N 56°04'39.26"E 12°55'05.63" |
|
|
|
|
|