Solved

totals by month between 1/1/2007 and 12/31/2007

Posted on 2006-11-29
2
222 Views
Last Modified: 2008-02-01
hello all,

I need to pull records from my table totaled by month between the date ranges of 1/1/2007 and 12/31/2007.

My table is called brfmaster, and my date field is called MDATE. I need to pull totals for each month based on MDATE basically, and need some help with the syntax.

thnx

mack1er
0
Comment
Question by:mack1er
2 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
Comment Utility
select datepart(month, mdate) m, count(*)
from brfmaster
where mdate >= convert(datetime, '2007-01-01', 120)
and mdate < convert(datetime, '2008-01-01', 120)
group by datepart(month, mdate)
0
 

Author Comment

by:mack1er
Comment Utility
WOW that was fast! Thank you
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

743 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

16 Experts available now in Live!

Get 1:1 Help Now