If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > I want the 4th monday of the Month

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-23-08, 03:04
myle myle is offline
(Making Your Life Easy)
 
Join Date: Feb 2004
Location: New Zealand
Posts: 1,143
I want the 4th monday of the Month

I have done it

Code:
<%
Function NextDate(nmonth, nTh, myday)
    '*************************************************
    'thanks to
    'http://michaelthompson.org/technikos/holidays.php
    '*************************************************
    Select Case myday
        Case "Mon"
            nTargetday = 2
        Case "Tue"
            nTargetday = 3
        Case "Wed"
            nTargetday = 4
        Case "Thu"
            nTargetday = 5
        Case "Fri"
            nTargetday = 7
        Case "Sat"
            nTargetday = 0
        Case "Sun"
            nTargetday = 1
    End Select
    'if month = 13 them ad 1 to the year
    'not tested cause it only come once a year 
    'it should work
    if nmonth = 13 then
    nmonth = 1
    nyear = Year(Date) + 1 
    else
    nyear = Year(Date)
    end if
    nEarliestDate = 1 + 7 * (nTh - 1)
    nWeekday = Weekday(DateValue(nEarliestDate & "/" & nmonth & "/" & nyear), vbSunday)
    If nWeekday = nTargetday Then
        noffset = 0
    ElseIf nTargetday < nWeekday Then
        noffset = nTargetday + (7 - nWeekday)
    Else
        noffset = (nTargetday + (7 - nWeekday)) - 7
    End If
	'is the date pass the date in question
	'need add 1 month to it
    nextD = nEarliestDate + noffset & " " & MonthName(nmonth, True) & " " & nyear
    checkdate  = DateValue(nEarliestDate + noffset & "/" & nmonth & "/" & nyear)

    if  date > checkdate then
	    nexx = nmonth + 1
        NextDate = NextDate(nexx,nth,myday)
    else
		NextDate = nextD    
    end if
    
End Function


%>
to use just <%=NextDate(month(date),4,"Mon")%>
or

<%=NextDate(month(date),4,"Wed")%>

injoy

hope this help someone
__________________
hope this help

See clear as mud


StePhan McKillen
the aim is store once, not store multiple times
Remember... Optimize 'til you die!
Progaming environment:
Access based on my own environment: DAO3.6/A97/A2000/A2003
VB based on my own environment: vb6 sp5
ASP based on my own environment: 5.6
VB-NET based on my own environment started 2007
SQL-2005 based on my own environment started 2008
MYLE
Reply With Quote
Reply

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On