• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Getting Every Other Payday Friday Date [SOLVED]

Having problems getting the following code to get the next bi-weekly payday date.


The paydays are every other Friday, and because the next bi-weekly payday is this week (6/14), the code should return the value date of 6/14/13 (in whatever format as long as the date is essentially 6/14).


When it's Friday, the code should return the next payday Friday which would be 6/28 etc..


The code I'm using beneath is all I could find that wasn't an excel formula.

It returns the 6/14 but fails to return the subsequent accurate dates.

I found an abundance of formulas that do the job with ease, but I'll need to implement this into code so "I think" I won't be able to use formulas if I'm on the code side.


Any help is definitely appreciated! :)

[pre]
Code:
<br />
Dim NextPayDayDate As Date<br />
NextPayDayDate = DateAdd("d", 0, Date) + (8 - Weekday(Date, vbFriday))<br />
MsgBox NextPayDayDate<br />
[/pre]
 
I think I have it working. The 1/11/13 is the first pay Friday of the year (although it can be any date as long as it's a previous target Friday date).


I used a Mod formula, if anyone has a more elegant approach I'm all for it.


But this is resolved for now I suppose, thanks again guys!


Now Working :)


Debug.Print ((DateValue("5, 31, 2013") - Date) - (14 * ((DateValue("5, 31, 2013") - Date) 14)) + 14) + Date
 
Hi, indi visual!

Just a question, how do you identify if next payday is this Friday or the other next Friday? I think you should have a payday base or starting date, or something monthly tied, or so.

Regards!
 
Hey SirJB7!, Actually I noted in my question that the start base was this coming Friday (6/14), from that point every subsequent bi-weekly Friday etc. In my working example above I see now (by mistake) that I'm using 5/31/13 instead of 1/11/13 in my Debug.Print example. But it doesn't matter -and the code will produce the correct results either way because both of those dates are on the same bi-weekly toggle path.
 
Back
Top