Count number of entries per day

Posted on 2011-02-23
Last Modified: 2012-05-11

I need to count the numbers of entries per day in a database.

Then I need the result to be displayed so that I can see how many entries there were per day.

Question by:jensjakobsen
LVL 32

Expert Comment

ID: 34963879

select convert(datetime, datefield, 101) as Daily, Count(*)
from table
group by Daily

Author Comment

ID: 34963928
Thanks for a very quick response.

However that example showed me the number of 1 (one) per entry.


If the date 02/02/2011 had 12 entries I get 12 entries and not 02/02/2011 = 12

Let me know if I'm unclear.
LVL 18

Accepted Solution

sventhan earned 500 total points
ID: 34963945
select convert(varchar, datefield, 110) as Daily, Count(*)
from table
group by convert(varchar, datefield, 110)
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)


Author Comment

ID: 34963988

I love you.
LVL 32

Expert Comment

ID: 34964073
Missed the group by
LVL 40

Expert Comment

ID: 34964362
You can simply convert to DATE if you are on SQL Server 2008.
select convert(date, datefield) as Daily, Count(*) Cnt
from table1
group by convert(date, datefield)

Open in new window


Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Audit has been really one of the more interesting, most useful, yet difficult to maintain topics in the history of SQL Server. In earlier versions of SQL people had very few options for auditing in SQL Server. It typically meant using SQL Trace …
Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now