I need a function that would return true if the date provided was a payday or date of next few weeks paydays.
\r\n
\r\nPaydays are every 14 days on a Friday (not twice a month).
\r\n
\r\nI tried several attempts, but don\'t have a clue where to start, except that the function needs a reference date to calculate from. This is what I have so far, but again, I do not know what I am doing.
\r\n
\r\nCan someone please help ?
\r\n
\r\n
\r\n
Code:
\r\n
\' PayDay is defined as every 14 days from a fixed date of last know payday.\r\n Public Function isPayDay(ByVal RefDate As Date, ByVal dDate As Date) As Date\r\n Dim testDate As Date\r\n Dim iDay As Integer\r\n Dim iMonth As Integer\r\n Dim iYear As Integer\r\n Dim dayCounter As Integer = 14\r\n Dim weekCounter As Integer\r\n\r\n RefDate = DateSerial(2011, November, 4)\r\n\r\n iDay = Day(dDate)\r\n iMonth = Month(dDate)\r\n iYear = Year(dDate)\r\n\r\n RefDate = DateSerial(2011, November, 4) \' Starting Reference payday\r\n dDate = DateSerial(iYear, iMonth, iDay)\r\n\r\n For weekCounter = 1 To 51 Step 2 \' 26 paydays in a year.\r\n testDate = DateAdd("d", dayCounter, RefDate) \' Add dayCounter to Reference day\r\n dayCounter += 14 \' Add multiples of 14 to dayCounter\r\n Next\r\n\r\n isPayDay = testDate\r\n\r\n End Function\r\n
Thanks in Advance.
\r\n \r\n\r\n