Group:  Microsoft Access » microsoft.public.access.devtoolkits
Thread: Adding two years to a date

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Adding two years to a date
António Carriço 05.03.2006 16:58:50
Hi, everyone!
I could use some help.
I have a table that has two fiels: "DateofSale" and "EndofWarranty" both
standard date fields.
The first one is filled by the user on a form. I would like that the default
value for the second one is two years from the first date. Any ideias?

Thanks!

Re: Adding two years to a date
"Douglas J. Steele" <NOSPAM_djsteele[ at ]NOSPAM_canada.com> 05.03.2006 19:23:01
Since EndofWarranty can always be calculated, you shouldn't store it.

As fellow Access MVP John Vinson likes to say "Storing calculated data
generally accomplishes only three things: it wastes disk space, it wastes
time (a disk fetch is much slower than almost any reasonable calculation),
and it risks data validity, since once it's stored in a table either the
calculated value or one of the fields that goes into the calculation may be
changed, making the value WRONG."

Instead, create a query and put a computed field into the query. To add 2
years to a date, you use the DateAdd function, so in your query, add the
following to an empty cell on the Fields line:

EndOfWarranty: DateAdd("yyyy", 2, [DateOfSale])

Use the query wherever you would otherwise have used the table.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"António Carriço" <AntnioCarrio[ at ]discussions.microsoft.com> wrote in message
news:7FE1C1BC-9AF3-428E-A7A9-3ACB72080FE0[ at ]microsoft.com...
[Quoted Text]
> Hi, everyone!
> I could use some help.
> I have a table that has two fiels: "DateofSale" and "EndofWarranty" both
> standard date fields.
> The first one is filled by the user on a form. I would like that the
> default
> value for the second one is two years from the first date. Any ideias?
>
> Thanks!
>


Re: Adding two years to a date
António Carriço 07.03.2006 12:17:29
Thanks

"Douglas J. Steele" wrote:

[Quoted Text]
> Since EndofWarranty can always be calculated, you shouldn't store it.
>
> As fellow Access MVP John Vinson likes to say "Storing calculated data
> generally accomplishes only three things: it wastes disk space, it wastes
> time (a disk fetch is much slower than almost any reasonable calculation),
> and it risks data validity, since once it's stored in a table either the
> calculated value or one of the fields that goes into the calculation may be
> changed, making the value WRONG."
>
> Instead, create a query and put a computed field into the query. To add 2
> years to a date, you use the DateAdd function, so in your query, add the
> following to an empty cell on the Fields line:
>
> EndOfWarranty: DateAdd("yyyy", 2, [DateOfSale])
>
> Use the query wherever you would otherwise have used the table.
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no private e-mails, please)
>
>
> "António Carriço" <AntnioCarrio[ at ]discussions.microsoft.com> wrote in message
> news:7FE1C1BC-9AF3-428E-A7A9-3ACB72080FE0[ at ]microsoft.com...
> > Hi, everyone!
> > I could use some help.
> > I have a table that has two fiels: "DateofSale" and "EndofWarranty" both
> > standard date fields.
> > The first one is filled by the user on a form. I would like that the
> > default
> > value for the second one is two years from the first date. Any ideias?
> >
> > Thanks!
> >
>
>
>

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net