Returning a date value

LEXCERM

Registered User.
Local time
Tomorrow, 09:53
Joined
Apr 12, 2004
Messages
169
Hi All,

I have been working on this problem for hours, but I keep hitting a brick wall!

Basically, whatever date is entered in [field1], I want [field2] to return a date of the 15th of the following month. For example:-

01-02-2007 = 15-03-2007
31-08-2007 = 15-09-2007
23-12-2007 = 15-01-2008

Thanks in advance,
Paul.
 
If this in a query or on a form?
 
Last edited:
Actually, maybe this function in a standard module will help for either case:
Code:
Private Function NewDate(InDate As Date) As Date
'-- Return the 15th of the following month
If Month(InDate) = 12 Then
   NewDate = DateSerial(Year(InDate) + 1, 1, 15)
Else
   NewDate = DateSerial(Year(InDate), Month(InDate) + 1, 15)
End If

End Function
 
Disregarding Null an other unpleasant stuff, wouldn't
Code:
Private Function NewDate(InDate As Date) As Date
'-- Return the 15th of the following month
   NewDate = DateSerial(Year(InDate), Month(InDate) + 1, 15)
End Function
suffice?

BTW - didn't I see this question somewhere else, too?
 
Thanks RuralGuy and Roy! Problem resolved!

Rgds,
Paul.
 

Users who are viewing this thread

Back
Top Bottom