Show items dated before next bi-weekly payday

home70

Registered User.
Local time
Today, 15:58
Joined
Jul 10, 2006
Messages
72
I use a db for my checkbook register. My current job pays twice a month, on the 1st and the 15th. I use some code that allows only items dated before my next payday to be figured into my balance, so that anything dated past my next payday isn't figured into the balance until that payday gets here. For example, if today is 5/27 and I schedule an online payment for 6/4, that payment isn't subtracted from my balance until my payday on 6/1. Here is the code I use:

If todays date was between the 1st and the 14th of the month, I need transactions dated before the 15th to be included in the balance and here's how I find them:

IIf([DateTransaction]<DateSerial(Year(Date()),Month(Date()),15)

And if today's date is between the 15th and the last day of the month, I want the transactions dated before the first day of next month to be included in the balance. Here's how I do it:

IIf([DateTransaction]<DateSerial(Year(Date()),Month(Date())+1,1)

I'm changing jobs to one that pays every two weeks on Wednesday so I'm looking for the equivalent code to do the same thing for bi-weekly paydays.
 
Success!
(I'll post this here and at the other thread I started)
For anyone in the future who might be looking for this, here's the simplest way I know to do it:

Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As
Integer)

Dim FirstPayday As Date
Dim NumberOfDaysSince As Integer
Dim modulus As Integer
Dim DaysToNext As Integer
Dim nextpayday As Date

DateToday = Date
FirstPayday = #5/9/2007#
NumberOfDaysSince = DateDiff("d", FirstPayday, DateToday)
modulus = NumberOfDaysSince Mod 14
DaysToNext = 14 - modulus
nextpayday = Date + DaysToNext

Thanks to Bob Quintal on another forum who suggested I find the modulus of the 14 days periods between the first payday and today's date.
I guess I'll use this code unless anyone has any suggestions on how it could be improved. (I do realize I don't have to use the variable FirstPayday...)
Thanks.
 

Users who are viewing this thread

Back
Top Bottom