Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add months to Date 1

Status
Not open for further replies.

crystalfun

Programmer
Feb 8, 2001
39
0
0
US
I would like add # of months to a date then see a new date as the result

Eg
Date = 2/1/2002
months = 36
Desired result = 2/1/2005

What formula can I use to get the desired result?
 
Code:
Private Sub Form_Open(Cancel As Integer)
Me.Text0 = DateAdd("m", 36, Date)
End Sub
This will add 36 months on the current date and display it on TextBox

Zameer Abdulla
[sub]Jack of Visual Basic Programming, Master in Dining & Sleeping[/sub]
Visit Me
 
I am not so sure crystalfun needs to see this on a form. However, where ever this is needed, a simple expression in a control source like:
=DateAdd("m", 36, [Date])

Code should not be necessary and I expect the code provided might fail since Date is a function. This is a good reason to not give your objects names of reserved words or functions.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top