Calculate no of days in a month within a specified date range 
Author Message
 Calculate no of days in a month within a specified date range

I need a function to check the number of days within a
specified month.
For example :

Specified Period range (10 Jan 2003 and 28 Nov 2003),
check no of days in between a month.

1.      Input is 200301, the result is 10
2.      Input is 200311, the result is 28
3.      Input is 200303, the result is 31
4.      Input is 200304, the result is 30
5.      Input is 200212, the result is 0/Null
6.      Input is 200312, the result is 0/Null

Thanks



Sat, 26 Nov 2005 21:27:16 GMT  
 Calculate no of days in a month within a specified date range


Quote:
> I need a function to check the number of days within a
> specified month.
> For example :

> Specified Period range (10 Jan 2003 and 28 Nov 2003),
> check no of days in between a month.

> 1.     Input is 200301, the result is 10
> 2.     Input is 200311, the result is 28
> 3.     Input is 200303, the result is 31
> 4.     Input is 200304, the result is 30
> 5.     Input is 200212, the result is 0/Null
> 6.     Input is 200312, the result is 0/Null

  ' Adjust start of month
  dtStartOfMonth = DateSerial(SomeYear, SomeMonth, 1)
  If dtStartOfMonth < dtMinimumDate then
    dtStartOfMonth = dtMinimumDate

  End If

  ' Adjust end of month
  dtEndOfMonth = DateSerial(SomeYear, SomeMonth + 1, 0)
  If dtMaximumDate < dtEndOfMonth Then
    dtEndOfMonth = dtMaximumDate

  End If

  ' Compare values: make sure they're not overlapping
  If dtStartOfMonth < dtEndOfMonth Then
    varDaysWithin = DateDiff("d", dtStartOfMonth, dtEndOfMonth)

  Else
    ' Error value
    varDaysWithin = Null

  End If

Bear in mind that this is not tested!

Hope that helps

Tim F



Sun, 27 Nov 2005 02:43:34 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Calculate days within a period range

2. Date Range - using day and month

3. Calculating days in a month !!

4. Calculating working days each month

5. Date within a Range of Dates

6. difference between two dates ,in years,months,and days

7. Month/day mix-up (sometimes) in date-parsing

8. Adding days/ months/ years to date record

9. Function to find the last day or Date of a given month

10. Date format problem (month & day swapping)

11. Schedule Report with Last Month's Date Range

12. Date, Day, Month?

 

 
Powered by phpBB® Forum Software