I have a closed date field and a destruction date field both of which use
medium date format. I need the destruction date to be the closed date plus
ten years. Iam not sure what formula to use to do this.
|
|
0
|
|
|
|
Reply
|
Utf
|
12/1/2009 5:20:01 PM |
|
DateAdd is the function you need.
You may not need to store the destruction date in a table unless the 10-year
rule is subject to change (in fact you shouldn't unless it's subject to
change). You can return the destruction date by including this term in the
Query Builder:
Destruction-Date:DateAdd("yyyy", 10, [closed_date])
.... which will return the calculated date in a column headed
"Destruction-Date".
If you haven't come across it, the Expression Builder (look for the magic
wand labelled "builder...") will repay the effort of learning it. See:
http://office.microsoft.com/en-us/access/HA102549021033.aspx
If you do need to store the calculated date, you can use an update query to
update the table with the calculated value.
Phil, London
"WG" <WG@discussions.microsoft.com> wrote in message
news:3B48F8E9-42D1-4775-8320-5DF61D4D03E2@microsoft.com...
> I have a closed date field and a destruction date field both of which use
> medium date format. I need the destruction date to be the closed date
> plus
> ten years. Iam not sure what formula to use to do this.
|
|
0
|
|
|
|
Reply
|
Philip
|
12/1/2009 5:33:12 PM
|
|
In a query, something like below. Make sure that the closed date field name
is spelt correctly between the [ ] .
Destruction Date: DateAdd("yyyy", 10, [closed date])
However you shouldn't have a destruction date field in your table as you can
derive the data using something like above. In other words you should
calculate the destruction date as needed instead of storing it in a table.
Why? What happens if you change the closed date and forget to update the
destruction date? You will have inconsistant data. What happens if the
destruction date rule gets changed to 15 years? You'll need to fix all the
records already entered.
Here's another reason, but not exactly applicable to your situation. You
have a Date Of Birth field and an Age field in an Employee table. After a
full year the Age field will be wrong. It's better to just drop the Age field
and calculate the age from the Date Of Birth field as needed.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.
"WG" wrote:
> I have a closed date field and a destruction date field both of which use
> medium date format. I need the destruction date to be the closed date plus
> ten years. Iam not sure what formula to use to do this.
|
|
0
|
|
|
|
Reply
|
Utf
|
12/1/2009 6:07:01 PM
|
|
That is a very thorough answer. You say I should not store the date in the
table because it could change. I would like the date to change. If a file
is reopened, then closed again it will have a new closing date. Will this
information update with the formula you gave? Should I store this
information diffrently?
"Jerry Whittle" wrote:
> In a query, something like below. Make sure that the closed date field name
> is spelt correctly between the [ ] .
>
> Destruction Date: DateAdd("yyyy", 10, [closed date])
>
> However you shouldn't have a destruction date field in your table as you can
> derive the data using something like above. In other words you should
> calculate the destruction date as needed instead of storing it in a table.
>
> Why? What happens if you change the closed date and forget to update the
> destruction date? You will have inconsistant data. What happens if the
> destruction date rule gets changed to 15 years? You'll need to fix all the
> records already entered.
>
> Here's another reason, but not exactly applicable to your situation. You
> have a Date Of Birth field and an Age field in an Employee table. After a
> full year the Age field will be wrong. It's better to just drop the Age field
> and calculate the age from the Date Of Birth field as needed.
> --
> Jerry Whittle, Microsoft Access MVP
> Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.
>
>
> "WG" wrote:
>
> > I have a closed date field and a destruction date field both of which use
> > medium date format. I need the destruction date to be the closed date plus
> > ten years. Iam not sure what formula to use to do this.
|
|
0
|
|
|
|
Reply
|
Utf
|
12/1/2009 6:50:01 PM
|
|
This is precisely why you don't want to store the destruction date. If
someone changes the closed date or enters in a completely new record directly
into the table or via a query, you can't get the formula to work. You would
need to ensure that all records are entered into a form which will use code
or a macro to update the destruction date when a new record is entered or
existing record is changed.
Another possibility is to run an update query frequently during the day
which would update all the destruction dates. However this is also a bad idea
as there could be a gap between someone using a new record and the update
query running.
It is almost always a better idea to calculate something like your
destruction date as needed in a query, form, or report. The exception is when
you need to store something as it was in a point of time such as an invoice.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.
"WG" wrote:
> That is a very thorough answer. You say I should not store the date in the
> table because it could change. I would like the date to change. If a file
> is reopened, then closed again it will have a new closing date. Will this
> information update with the formula you gave? Should I store this
> information diffrently?
>
> "Jerry Whittle" wrote:
>
> > In a query, something like below. Make sure that the closed date field name
> > is spelt correctly between the [ ] .
> >
> > Destruction Date: DateAdd("yyyy", 10, [closed date])
> >
> > However you shouldn't have a destruction date field in your table as you can
> > derive the data using something like above. In other words you should
> > calculate the destruction date as needed instead of storing it in a table.
> >
> > Why? What happens if you change the closed date and forget to update the
> > destruction date? You will have inconsistant data. What happens if the
> > destruction date rule gets changed to 15 years? You'll need to fix all the
> > records already entered.
> >
> > Here's another reason, but not exactly applicable to your situation. You
> > have a Date Of Birth field and an Age field in an Employee table. After a
> > full year the Age field will be wrong. It's better to just drop the Age field
> > and calculate the age from the Date Of Birth field as needed.
> > --
> > Jerry Whittle, Microsoft Access MVP
> > Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.
> >
> >
> > "WG" wrote:
> >
> > > I have a closed date field and a destruction date field both of which use
> > > medium date format. I need the destruction date to be the closed date plus
> > > ten years. Iam not sure what formula to use to do this.
|
|
0
|
|
|
|
Reply
|
Utf
|
12/1/2009 8:29:01 PM
|
|
Yes, the destruction date will be recalculated by the query when the closing
date is changed. The destruction date is NOT stored, but is always
calculated. See Jerry Whittle's paragraph below.
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
WG wrote:
> That is a very thorough answer. You say I should not store the date in the
> table because it could change. I would like the date to change. If a file
> is reopened, then closed again it will have a new closing date. Will this
> information update with the formula you gave? Should I store this
> information diffrently?
>
> "Jerry Whittle" wrote:
>> Why? What happens if you change the closed date and forget to update the
>> destruction date? You will have inconsistant data. What happens if the
>> destruction date rule gets changed to 15 years? You'll need to fix all the
>> records already entered.
|
|
0
|
|
|
|
Reply
|
John
|
12/1/2009 8:31:32 PM
|
|
|
5 Replies
278 Views
(page loaded in 0.623 seconds)
Similiar Articles: Calculating a future date - microsoft.public.access.gettingstarted ...I have a closed date field and a destruction date field both of which use medium date format. I need the destruction date to be the closed date plu... calculate 6 months forward from a date - microsoft.public.excel ...Please can someone help, I need a formula to calculate a date 6 months forward from another date and return the future date as the answer in a cell.... calculate date of birth with an end date and age - microsoft ...Calculating a future date - microsoft.public.access.gettingstarted ... It's better to just drop the Age field > > and calculate the age from the Date Of Birth field as ... Calculating Date Fields - microsoft.public.word.vba.general ...Calculating Dates with Fields (Microsoft Word) Aidan asked if it is possible to calculate dates using fields. Seems he wants a date that is two weeks in the future, and ... returning a date 7 business day excluding holidays in the future ...Excel :: Calculate Future Date Excluding Weekends Datedif But For Date In Future And To Return ... For WeekEnds/After Business Hours; Add X Days To Date Excluding ... Calculating calendar days and completion dates. - microsoft.public ...Calculating a future date - microsoft.public.access.gettingstarted ... Calculating calendar days and completion dates. - microsoft.public ... Calculating a future date ... Calculating dates to include Saturdays but not Sundays - microsoft ...Calculating a future date - microsoft.public.access.gettingstarted ... Calculating dates to include Saturdays but not Sundays - microsoft ... Calculating dates to include ... Calculate the number of days to exclude Sunday & Holidays ...* this formula is specifically written to calculate *future dates* so the number of workdays must be a positive number. -- Biff Microsoft Excel MVP "LSG" <LSG ... Calculate Daily Interest, Paid out Weekly - microsoft.public.excel ...Calculating a future date - microsoft.public.access.gettingstarted ... Calculate Daily Interest, Paid out Weekly - microsoft.public.excel ... There is a formula > for ... Calculate difference between current date & prior - microsoft ...Calculator: Add to or subtract from a date The Date Calculator calculates the duration between 2 dates. ... and years to a date to calculate a past or future date. ... Calculator: Add to or subtract from a dateDate calculator: Add to or subtract from a date. This service enables you to add or subtract days, months and years to a date to calculate a past or future date. How to Calculate a Future Date in Excel | eHow.comTo calculate a future date in Excel, use a formula that adds one or more days to an existing date. For example, you can type a date into a cell, and then type a ... Calculating past and future dates < PHP | The Art of WebPHP: Calculating past and future dates. The strtotime function in PHP is incredibly powerful but very much underutilised - mainly because some aspects can be a bit ... How to Calculate a Date in Excel | eHow.comMicrosoft Excel has various functions that are available to calculate dates. There are functions that bring back the current date, past dates, future dates and the ... Calculating a future or past date in Access - Access - Office.comApplies to Microsoft Office Access 2003 Microsoft Access 97, 2000 and 2002 In Access, you can calculate a future or past date from a starting date by using an expression. 7/14/2012 2:19:53 PM
|