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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

date() + 12 months

Status
Not open for further replies.

jamesmills

Technical User
Jul 30, 2003
43
GB
Hey hows it going
I would like to set a default value
i would like it to be 12 months from the current date

any advise please

thanks
 
This will add one year to the current date. There you can add days, years, months by changing the field that is currently yyyy.

DateAdd("yyyy", 1, Date)
 
dont quite understand what you said?
i tried to put it into access and change a few things but it came up with error.....

So if i wanted to add one year (12 months) onto todays date i would.....?
 
sorry, left somthing out

TextBox = DateAdd("yyyy", 3, Me.Servers_PurchaseDate)
 
right but can i not put it in the default section without having to put it in the VB code bit....

in the defalut bit for todays date i put Date()....
like that?
 
nope not working?

adding '= DateAdd("yyyy", 3, Date) ' to default vaule of a date feild in a table
 
Well, a default of "=Date()+365" will give you 7/29/2004 because of leap year, so that's not 100% accurate but it's close. Use it for now and maybe I can figure out something or one of the local wizards around here will figure it out. Good luck.

Jim DeGeorge [wavey]
 
This works...

=DateAdd("yyyy",1,Date())

I don't know what the "3", I got that from Jason's post. And I left out the () after "Date", which normally you don't need.

Jim DeGeorge [wavey]
 
sorry bro but it is still not working on mine?

=DateAdd("yyyy",1,Date())
i had tried it with the () after the date befor..... says it is missing an operator?
 
ok it works now...... sorry just me being a fool..... thanks again
 
I put this code in the onCurrent event of a form:

Text304 = DateAdd("yyyy", 1, Date)

And when I viewed the form, the box contained the date, one year from today. So it looks like you need to use this code in a module, rather than using it as a source for a textbox. But you can set it as the source for a textbox inside a module, which is what I have done above.
 
Jason

It worked fine as the DEFAULT of the form's text box. Why the extra effort of a module?

Jim DeGeorge [wavey]
 
I thought it wasn't working like that, so I was giving him another option. But I guess I just misunderstood.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top