Microsoft Access Developer Question: Download Microsoft Access Developer PDF
Tell me how do I add (or subtract) time differences to (or from) a date?
Answer:
Access has many date manipulation functions - see Help for a full list.
Example - add 1 year to the system date:
=Date() uses the Date function and will give today's date (the system date).
=DateAdd ("yyyy",1, Date()) uses the DateAdd function to add one year to today's date.
You cannot reference another field in an expression like this in a table definition. But you could do so in VBA code for a data entry form, or in a calculated field in a query, for example.
=Date() + 365 will give a date in a year's time, but will not work for leap years!
Example - add 1 year to the system date:
=Date() uses the Date function and will give today's date (the system date).
=DateAdd ("yyyy",1, Date()) uses the DateAdd function to add one year to today's date.
You cannot reference another field in an expression like this in a table definition. But you could do so in VBA code for a data entry form, or in a calculated field in a query, for example.
=Date() + 365 will give a date in a year's time, but will not work for leap years!
Previous Question | Next Question |
Tell us what is the tag property and how can it be used? | Tell me the tabledefs collection represents only open tables. (True or False)? |