Insert the current date and time with the default value field property
In this Microsoft Access video tutorial, you will
learn how to use the Default Value property in your tables to
automatically insert the current date and time into new records.
This is great for work logs, order entry, or anything else that requires
a date/time stamp. You can learn more about the Default Value property,
and many of the other table field properties in my Access
2010 Beginner Level 3
Have you ever wanted to automatically insert the current date and time into your
Microsoft Access database records? You can do this with the Default Value
property. You can use this for work logs, order entry, time tracking, or
anything else that requires a simple date/time stamp to be automatically entered
each time you create a new record.
Take, for example, a simple table with three fields: an ID (AutoNumber), a
DateTime field (Date/Time data type), and a Description field (Text). As you
enter records into the table, you are forced to manually type in the current
date and time for each record. This can be quite laborious, even with the Date
Picker button, because you still have to type in the time. It would be nice if
there was a way for Access to automatically insert the current date and time for
Open your table in Design View. Click on the DateTime field and notice the list
of field properties at the bottom of the window. Find the Default Value
property. The Default Value is the value that a new record starts out with. You
can change it if you want, but Access will create new records with this value.
You can set the Default Value to a static value. For example, if most of your
customers are from New York, you could set the Default Value for a State field
to �NY�. In this case, we want the current date and time to be inserted.
In order to have a Default Value that inserts the current date, type the
following into the Default Value property:
This is the Date Function. Notice the empty parentheses. This indicates to
Access that you�re dealing with the Date Function, and not just the word �Date.�
The Date Function returns the current date and places it in this field. Since
Date() doesn�t return the time, we�ll get today�s date at midnight. If you save
the table and switch over to Datasheet View, you�ll see that the next new record
will be created with today�s date. Now, we want the current date with the
current time. So instead of Date() type in:
The Now Function returns the current date along with the current time. This will
allow you to create a date/time stamp for your record. Each time you enter a new
record, the date and time are inserted automatically for you.