Date diffrence in days, weeks and months.

Joined
Feb 3, 2019
Messages
14
Reaction score
0
Hi. I have a columb A21 with a custom date of Wed 07 Desc-2022. Columb B has =NOW()-A21
I would like columb C=weeks and possibly D=months.

Is this possible?

I added a cell A22 the current date NOW() and made the formula read DATEDIF(A21, A22,"d").
 
Last edited:
Joined
Nov 2, 2022
Messages
19
Reaction score
0
create a Public function in a Module:

Public Function fnDateDiff(ByVal interval As String, ByVal Date1 As Date, Date2 As Date) As Variant
' for now interval can be "w" (week) or "m" (month)
If interval <> "w" And interval <> "m" Then
fnDateDiff = Null
Exit Function
End If
fnDateDiff = VBA.dateDiff(interval, Date1, Date2)
End Function


to get the Weeks:
=fnDateDiff("w", A21, A22)

to get the Months:
=fnDateDiff("m", A21, A22)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top