Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
MySQL General discussion about the MySQL database.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the MySQL section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 3rd, 2007, 11:24 PM
Registered User
Join Date: May 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default find days per month in a date range

How to find days per month in a date range ?

For eg i have a start date - 04/28/2007 (mm/dd/Y) and end date 05/04/2007 , i have to find the days in each month that comes in the above date range

in the above eg the days in April are 3 and in May the days are 5

Reply With Quote
  #2 (permalink)  
Old June 5th, 2007, 07:36 PM
Friend of Wrox
Join Date: Jul 2003
Location: South San Francisco, CA, USA.
Posts: 128
Thanks: 0
Thanked 1 Time in 1 Post


try this:
SELECT DATEDIFF(start_date, LAST_DAY(start_date)) + 1 AS rdosd,
DAYOFMONTH(end_date) AS doed
FROM TableOfDates;

rdosd: Remaining Days of start_date
doed: Days of end_date

Hope it works,

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using month & year variable to get date in range rsearing ASP.NET 2.0 Professional 2 July 5th, 2008 08:30 AM
Finding nday of evry month within date range arnabghosh Classic ASP Professional 0 December 6th, 2007 01:42 AM
VBA Macro FIND THIS MONTH in a given range mvatoi Excel VBA 3 August 24th, 2007 08:12 AM
How to find a date range between another date rang tayvonne Access 2 August 3rd, 2006 09:50 AM
Days in a Month jmss66 Classic ASP Basics 3 April 11th, 2005 05:57 PM

All times are GMT -4. The time now is 09:52 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.