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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 1st day of previous month only

Author  Topic 

masterdineen
Aged Yak Warrior

550 Posts

Posted - 2011-02-04 : 11:10:29
How did i select the 1st day of previous month only

I only want the day number. eg 01, 15

MCTS / MCITP certified

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-02-04 : 11:26:46
This doesn't make sense. The first day of the previous month is always 1.

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

masterdineen
Aged Yak Warrior

550 Posts

Posted - 2011-02-04 : 11:33:47
lol sorry i have had a few pints

i meant to say.

How do you select only the day. from (SELECT DATEADD(month,datediff(month,0,getdate())-1,0))

The above shows the first day of the previous month.
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-02-04 : 11:42:14
I'm still guessing
SELECT DATENAME(weekday,DATEADD(month,datediff(month,0,getdate())-1,0) )

Perhaps you can give an example of the input and what you're expected output is.

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page
   

- Advertisement -