By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,469 Members | 2,402 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,469 IT Pros & Developers. It's quick & easy.

Adding years

100+
P: 153
I've got a quick question, I think...I thought it would be simple but suprisingly I can not find a solution so here it goes

I'm trying to find a way that I can add years to a date. I have a field that contains integers that represent a number of years. So, for example, I might have one field that's equal to 2 so that represents 2 years and I'd like to add those 2 years to a date such as 4/15/2006

Any help would be much appreciated. Thanks.
Jan 8 '07 #1
Share this Question
Share on Google+
3 Replies


ADezii
Expert 5K+
P: 8,597
I've got a quick question, I think...I thought it would be simple but suprisingly I can not find a solution so here it goes

I'm trying to find a way that I can add years to a date. I have a field that contains integers that represent a number of years. So, for example, I might have one field that's equal to 2 so that represents 2 years and I'd like to add those 2 years to a date such as 4/15/2006

Any help would be much appreciated. Thanks.
'You did not specify whether you wanted to make this addition in a Table or Form, so I assumed a Form View:

[txtDate] - Field containing the Date to be added to
[txtYears] - Field containing the Integer number of years
[txtNewDate] - Field that will contain the New Date

Expand|Select|Wrap|Line Numbers
  1. Me![txtNewDate] = DateAdd("yyyy", Me![txtYears], Me![txtDate])
Jan 8 '07 #2

100+
P: 153
'You did not specify whether you wanted to make this addition in a Table or Form, so I assumed a Form View:

[txtDate] - Field containing the Date to be added to
[txtYears] - Field containing the Integer number of years
[txtNewDate] - Field that will contain the New Date

Expand|Select|Wrap|Line Numbers
  1. Me![txtNewDate] = DateAdd("yyyy", Me![txtYears], Me![txtDate])
Ahh my mistake...it is adding it to a table
So I would do something like recSet7.Fields("Date") = DateAdd("yyyy", recSet7.Fields("Years"), recSet7.Fields("Date") ?
Jan 8 '07 #3

100+
P: 153
This actually should work. Thanks! :)
Jan 8 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.