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 |
dwalker79
Yak Posting Veteran
54 Posts |
Posted - 2008-06-02 : 15:06:46
|
Hello,I'm trying to figure out how to retrieve the last day of the prior month in a specific format. I know I can use:select CONVERT(VARCHAR(11),dateadd(ms,-3,DATEADD(mm, DATEDIFF(mm,0, getdate() ), 0)))This will give me the the last day of the prior month as "May 31 2008", however I need the format to be 05-31-2008, which is the 110 format. The DATEDIFF function won't allow me to simply add 110 after the getdate() function.Can someone please help me??Thanks!!Dustin |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-02 : 15:09:02
|
select CONVERT(VARCHAR(11),dateadd(ms,-3,DATEADD(mm, DATEDIFF(mm,0, getdate() ), 0)),110) |
 |
|
dwalker79
Yak Posting Veteran
54 Posts |
Posted - 2008-06-02 : 15:12:40
|
Wow, I thought I tried that but I guess I didn't. THANK YOU VERY MUCH!! |
 |
|
|
|
|
|
|