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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 getting a date?

Author  Topic 

tehPwnDeveloper
Starting Member

2 Posts

Posted - 2008-04-19 : 13:11:41
No ... not with the opposite sex ;)

I need to be able to find the first thursday of NEXT month. There are some questions on here about how to find the current month's days ... but nothing about next month. Can anyone help? Thanks in advance for looking :)

nr
SQLTeam MVY

12543 Posts

Posted - 2008-04-19 : 13:37:25
First day of next month is
select dateadd(mm,1,dateadd(dd,datepart(dd,getdate())*-1,getdate())+1)
Then as for current month


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

tehPwnDeveloper
Starting Member

2 Posts

Posted - 2008-04-19 : 13:44:30
how do I find named day of the month? I don't need the first day of the month, I need the first Thursday of next month.
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2008-04-19 : 13:51:16
>> There are some questions on here about how to find the current month's days
You should be able to use the same processing as you have found here starting with the begining of the month.

maybe
select dte.d
from
(select i=0 union all select 1 ... union all select 6) num
cross join (select d = dateadd(mm,1,dateadd(dd,datepart(dd,getdate())*-1,getdate())+1)) dte
where datename(dw,dte+num.i) = 'Thursday'


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -