473,395 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Adding years

153 100+
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
3 1357
ADezii
8,834 Expert 8TB
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
Kosmos
153 100+
'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
Kosmos
153 100+
This actually should work. Thanks! :)
Jan 8 '07 #4

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

Similar topics

3
by: Meyer1228 | last post by:
We're converting an old database using text files for input and output. Their solution for Y2K has 48 years subtracted from the date field.. Our input now has the year field with 48 years less...
4
by: Rhamphoryncus | last post by:
First a bit about myself. I've been programming in python several years now, and I've got several more years before that with C. I've got a lot of interest in the more theoretical stuff (language...
58
by: Jon Glazer | last post by:
I have an anchor using a class that defines a hover subclass. The issue is that the anchor itself doesn't have any border and when hovered it adds a border, the problem is that when it adds the...
10
by: sp0 | last post by:
Is there a reason why to make mix numbers improper when adding? It seems when subtracting and adding, adding a subtracting the whole numbers and fraction parts should be sufficient? what'ch think
17
by: Rune Strand | last post by:
Is it an idea to include a new __filename__ predefined attribute to 2.5, so that __file__ contains the entire path to the module, and __filename__ only the name of the module? For instance it's...
32
by: Ed Jay | last post by:
A complete js newbie is asking this question: I have a form comprised of several questions, each answered with a radio button. I'd like to use onClick to bring up additional text at the end of...
14
by: Karl Irvin | last post by:
While adding data to a record set, I use something like rst! = some variable rst! = some variable ...... rst! = some variable The rst! , rst! etc. are manually typed in and it gets...
2
by: dympna | last post by:
Hi can anyone suggest a fix for this... as I am a novice in access. I have created a training table with the following fields Employee Name - joe Training Received - Fork lift Date Received...
4
by: zoeb | last post by:
Hi. I have a form which the user enters 2 years worth of data into (one record per year). The aim, is to populate the table this form is based on with 3 more years worth of data (i.e. creating 3...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.