Posted By

Scooter on 03/12/08


Tagged

DateTime


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

f0vela
ckayra
asifrizvigmailcom


Number of days in a month


 / Published in: ASP
 

URL: http://reusablecode.blogspot.com

Returns the number of days in a given month for a given year. Requires my isLeapYear() function available here: http://snipplr.com/view/5388/check-if-a-year-is-a-leap-year/

  1. <%
  2. ' Copyright (c) 2008, reusablecode.blogspot.com; some rights reserved.
  3. '
  4. ' This work is licensed under the Creative Commons Attribution License. To view
  5. ' a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or
  6. ' send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California
  7. ' 94305, USA.
  8.  
  9. ' Returns the number of days in a given month (and in the case of February, for the given year).
  10. ' REQUIRES: isLeapYear()
  11. function MonthDays(someMonth, someYear)
  12. select case someMonth
  13. case 1, 3, 5, 7, 8, 10, 12
  14. MonthDays = 31
  15. case 4, 6, 9, 11
  16. MonthDays = 30
  17. case 2
  18. if isLeapYear(someYear) then
  19. MonthDays = 29
  20. else
  21. MonthDays = 28
  22. end if
  23. end select
  24. end function
  25. %>

Report this snippet  

You need to login to post a comment.