Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accounts opened per day, per month, per year

Status
Not open for further replies.

dwight1

IS-IT--Management
Aug 22, 2005
176
US
Hi Guys,

I have a date field and the name of the account. I want to make a view/sp/function that would give me the
1. Number of accounts opend yesterday.
I am using DATEDIFF(D, CONVERT (datetime, DateOpend), GETDATE()) and setting a criteria as 1 and grouping to know the accounts opened.
2. Number of accounts opend This Month.
Another query to sort by date and month using DATENAME(MONTH, DateOpend).
3. Number of accounts opend This Year.

Right now, i am using many queries to reach to the solution.

Is there a better way of handling this information.

I want to see the result the following way.

Accountsopendyesterday ThisMonth Thisyear
32 320 3200

Thanks

Dwight
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top