Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 3rd, 2007, 11:24 PM
Registered User
 
Join Date: May 2007
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

 
Old June 5th, 2007, 07:36 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 128
Thanks: 0
Thanked 1 Time in 1 Post
Default

rojer,

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,
john









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





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