Locopete99
Registered User.
- Local time
- Today, 08:58
- Joined
- Jul 11, 2016
- Messages
- 163
Hi Guys,
I need to find the difference in months between two values.
One value would be Now() the second a date from a record.
The only problem is that I would need to re-constitute the date from the record.
The date on the record is being entered as "Sept-17" for example.
Using the idea that some times its easier to work around bad habits instead of trying to change the way a lot of people work I have made the below code.
This works in re-constituting the date, but I dont seem to be able to use it with the datediff function.
Any help?
I need to find the difference in months between two values.
One value would be Now() the second a date from a record.
The only problem is that I would need to re-constitute the date from the record.
The date on the record is being entered as "Sept-17" for example.
Using the idea that some times its easier to work around bad habits instead of trying to change the way a lot of people work I have made the below code.
This works in re-constituting the date, but I dont seem to be able to use it with the datediff function.
Any help?
Code:
Dim m1 As String
Dim m2 As Variant
Dim d1 As Date
Dim ye1 As Variant
Dim ddif As Variant
m1 = DLookup("[Month 12]", "Tbl_Forecast", "[Subba2]=" & "'" & [Subba] & "'")
m2 = Month(m1)
If m2 < 10 Then
m2 = "0" & Month(m1)
Else
m2 = Month(m1)
End If
ye1 = "20" & Right(m1, 2)
d1 = "01/" & m2 & "/" & ye1
ddif = DateDiff(m, d1, Now())