Daily Report Using DATEPART in SQL
Daily Report Using DATEPART in SQL
Mar 10I was working on a query today that I have never tackled before and thought I would share. We wanted to see what our highest one day total for applications received were on our carrers page.
First step was to group by each of the date. I am sure there is a DateTime function in SQL that I don’t know that would have made this eaiser, but I got arround my limitation with DATEPART. I extracted the year, the month and the day and grouped by each of them.
GROUP BY DATEPART(yy, CreateDate), DATEPART(mm, CreateDate), DATEPART(DD, CreateDate)
Then it is as simple as counting one of the elements that has been grouped. My final query:
SELECT COUNT(DATEPART(yy, CreateDate)) AS Total, DATEPART(yy, CreateDate) AS Year, DATEPART(mm, CreateDate) AS Month, DATEPART(DD, CreateDate) AS Day FROM JobApplications GROUP BY DATEPART(yy, CreateDate), DATEPART(mm, CreateDate), DATEPART(DD, CreateDate) ORDER BY Year DESC, Month DESC, Day DESC
There it is, a total number of applications recieved per day.

just what i was looking for !
Is this query can automatic generate the report? How if I want to set to generate report every day 4pm?
What is the solution?
Yea nice Work !:D
Searching for this for some time now – i guess luck is more advanced than search engines
Interesting … as always – is your blog making any cash advance ?
Nice resource. rss feed added
Your blog is so informative … keep up the good work!!!!
my God, i thought you were going to chip in with some decisive insght at the end there, not leave it with ‘we leave it to you to decide’.
good good…this post deserves nothing
…hahaha just joking
…nice post
Nice resource. rss feed added
That’s great. Just what I needed. Thanks!
Do not turn back when you are just at the goal.
Gramma, did you write this? It’s not bad, I guess.
thanks! very helpful post!! like the template btw
Fresh activity is the only means of overcoming adversity.
Of course, what a great site and informative posts, I will add backlink – bookmark this site? Regards, Reader.
Interesting article. Were did you got all the information from? Anyway thank you for this great post!
Watch Naruto Episode and Naruto Shippuden Weekly Update!!
We have all the Naruto Shippuuden episodes and Naruto Episode 1-220.
I entered your blog from google search. You really have done a good effort. Thanks for the wonderful blog.
I want to thank you for this informative read, I would like to read more of your blogs and to share my thoughts with you.
Jack was out kissing babies while I was out passing bills. Someone had to tend the store.
Just wanted to say thanks for this.
Hi – very great web site you have created. I enjoyed reading this posting. I did want to write a comment to tell you that the design of this site is very aesthetically pleasing. I used to be a graphic designer, now I am a copy editor in chief. I have always enjoyed playing with information processing systems and am attempting to learn code in my free time.
Great website…and cool article man…thanx for the great post…keep on posting such articles… Resources like the one you mentioned here will be very useful to me! I will post a link to this page on my blog. I am sure my visitors will find that very useful.
:O So mush Info :O : THis Is he MOst AMAzing SIte DUDe:
The theme you’re be using to show off your content material is wonderful! Wherever can I locate it?
I would like to recommend anybody reading this to view the feedback above complimenting this blog to show how unnecesarry it will possibly be.