Posted By

Scooter on 11/01/08


Tagged

DateTime


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

sulfurito
asifrizvigmailcom


Nth Day


 / Published in: ASP
 

URL: http://reusablecode.blogspot.com/2008/11/nth-day.html

  1. <%
  2. ' Returns the date of the Nth day for a given month in a given year.
  3. function nthDay(someYear, someMonth, someWeek, someWeekday)
  4. dim firstDay
  5. dim someDay
  6.  
  7. firstDay = weekday(dateSerial(someYear, someMonth, 1))
  8.  
  9. ' Check if the week day of the first day of the month is before or after the given week day.
  10. if (someWeekday - firstDay) >= 0 then
  11. someDay = 1 + (someWeekday - firstDay) + ((someWeek - 1) * 7)
  12. else
  13. someDay = 1 + (someWeekday - firstDay) + (someWeek * 7)
  14. end if
  15.  
  16. nthDay = dateSerial(someYear, someMonth, someDay)
  17. end function
  18. %>

Report this snippet  

You need to login to post a comment.