Solved

Need to create a monthly report and need help with how to get dates or # of days in a month

Posted on 2008-10-10
1
149 Views
Last Modified: 2012-05-05
I need to run a sql query either the first day of the month and look at the previous month or run the last day of the month and look for all days in the current month.
How would I code this?
This is what we are doing now.
WHERE     (Incident.CreatedDateTime >= GETDATE() - 30)
we determine the number of days in the month and run it on the first day of the month manually.
We would like to automate this.
0
Comment
Question by:FLPeople
1 Comment
 
LVL 32

Accepted Solution

by:
Daniel Wilson earned 125 total points
Comment Utility
subtract a month, not a number of days.  Use SQL's DateAdd to do so.

WHERE     (Incident.CreatedDateTime >= DateAdd(m, -1, GETDATE() ) 

Open in new window

0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Join & Write a Comment

I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

772 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

11 Experts available now in Live!

Get 1:1 Help Now