Pay dates between two dates

daveasu

Board Regular
Joined
Jan 4, 2012
Messages
53
I'm attempting to calculate the dates for payroll for contract labor. Our payroll is on the 1st and 15th of the month.

Contract dates are:
A1 has the Start Date: 6/23/2019
A2 has he End Date: 8/17/2019

I'm using this formula to calculate the number of pay periods:
=SUMPRODUCT(--(DAY(ROW(INDIRECT(A1&":"&A2)))={1,15}))

Which is returning the value of 4 (the number of pay periods between the dates)

However, since the end date is 2 days into the next pay period, there are actually 5 pay periods.

07/01/2019
07/15/2019
08/01/2019
08/15/2019
09/01/2019

Is there a formula that can calculate the 5 pay periods and return the pay date of each pay period based on the contract start and end dates?
 
Last edited:

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Maybe...

=SUMPRODUCT(--(DAY(ROW(INDIRECT(A1&":"&A2)))={1,15}))+IF(AND(DAY(A2)<>1,DAY(A2)<>15),1,0)

M.
 
Upvote 0
if you would rather have the dates, try this UDF:
Code:
Function PayDays(FromDate As Date, ToDate As Date) As String
    For PDate = FromDate To ToDate
        If Day(PDate) = 1 Or Day(PDate) = 15 Then
            result = result & ", " & Format(PDate, "mm/dd/yyyy")
        End If
    Next PDate
    If Day(PDate) < 15 Then
        result = result & ", " & Format(DateSerial(Year(PDate), Month(PDate), 15), "mm/dd/yyyy")
    Else
        result = result & ", " & Format(DateSerial(Year(PDate), Month(PDate) + 1, 1), "mm/dd/yyyy")
    End If
    PayDays = Mid(result, 3, 999)
End Function
 
Upvote 0
Thank you Marcelo! That worked perfectly! Repush thank you! Yes, I would like to have the dates as well. It will take me a day or two to get my VBA hat on correctly and give this a try! :)

Thank you both!
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,376
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top