DateAdd???

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have found some advice in regard to DateAdd which seems to be a good way of
generating a date in the future.

What I have been unable to find is whether this can be used in a table or
only in a form as the help on the subject is limited in this respect.

Thank You
 
It depends on exactly how you want to use it in the table. You can use it,
for example, in the Default Value property of a Date/Time field ...

=DateAdd("d",10,Date())

.... or in the Validation Rule property of a Date/Time field ...
=DateAdd("d",10,Date())

.... or in the Validation Rule property of the Table ...

[RequiredDate]>=DateAdd("d",1,[OrderDate])

If you mean you want to use it to create a calculated column within the
table, no, but you can do it in a query. In the 'Field' row in the query
design grid, enter an expression such as ...

TestDate: DateAdd("d",10,[OrderDate])

.... where 'TestDate' is whatever 'alias' or heading you want to give the
calculated column.
 
My table has a lot of fields but specifically for this one I have a 'Start
Date' and a 'Target Reply Date' this is the field that I need to have a plus
28 days from the start date as we have a target to uphold.

If I ran it in a query I could just read the data within a query rather than
the table but the query could be designed to look just like the table so it
wouldnt make much of a difference to my workings.

Hopefully that will work because yesterday AutoUpdate failed me.

Thank You

Brendan Reynolds said:
It depends on exactly how you want to use it in the table. You can use it,
for example, in the Default Value property of a Date/Time field ...

=DateAdd("d",10,Date())

.... or in the Validation Rule property of a Date/Time field ...
=DateAdd("d",10,Date())

.... or in the Validation Rule property of the Table ...

[RequiredDate]>=DateAdd("d",1,[OrderDate])

If you mean you want to use it to create a calculated column within the
table, no, but you can do it in a query. In the 'Field' row in the query
design grid, enter an expression such as ...

TestDate: DateAdd("d",10,[OrderDate])

.... where 'TestDate' is whatever 'alias' or heading you want to give the
calculated column.

--
Brendan Reynolds
Access MVP

Nixxie said:
I have found some advice in regard to DateAdd which seems to be a good way
of
generating a date in the future.

What I have been unable to find is whether this can be used in a table or
only in a form as the help on the subject is limited in this respect.

Thank You
 
My table has a lot of fields but specifically for this one I have a 'Start
Date' and a 'Target Reply Date' this is the field that I need to have a plus
28 days from the start date as we have a target to uphold.

If I ran it in a query I could just read the data within a query rather than
the table but the query could be designed to look just like the table so it
wouldnt make much of a difference to my workings.

You need not - and SHOULD NOT - be opening *EITHER* a Table or a Query
for user interaction. Table/query datasheets are of very limited
utility; they're not really designed for that purpose.

I'd put these calculated dates as fields in a Query (you cannot put
them in a Table, tables only contain "real" data not expressions) and
base a Form on the query for user interaction. You really should only
store the target date in any table at all *if* it's intended to be
editable independently of the start date; if it's always 28 days after
Start Date then *just* calculate it, in a query or form.

John W. Vinson[MVP]
 
Back
Top