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)
 Month dates

Author  Topic 

TMDOSS
Starting Member

33 Posts

Posted - 2009-08-07 : 20:27:09
How can I get data for the Current month.
for Example I need to return all the calls made for this month from the table
I have
Date Called Name
I need the stored Procedure to return the value use name who made calls in the current month. so that there is no need to change the dates every month

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2009-08-07 : 20:59:13
Post sample data and desired results


Success is 10% Intelligence, 70% Determination, and 22% Stupidity.
\_/ _/ _/\_/ _/\_/ _/ _/- 881
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-08-07 : 22:19:22
[code]
select *
from call_table
where [Date] >= dateadd(month, datediff(month, 0, getdate()), 0)
and [Date] < dateadd(month, datediff(month, 0, getdate()) + 1, 0)
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -