date field

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

Guest

can i have a date field that is just a year and the computer recognises it as
a date?
 
Yes, set the control source of a text box to:
=Format([nameofyourdatefield],"yyyy")
 
No, it is not possible, as a year is not a date. It is certainly possible to
display only the year part of the date (that is what rico's suggestion
elsewhere in this thread does) but it is not possible to store only a year
in a date field, a date field always contains a complete date and time.
Neither will Access, Jet, or VBA 'recognize' a year as a date - which is a
good thing, because a year is not a date. If you want to perform some kind
of date-oriented operation on the value, you will have to supply a month and
day as well.

To extract a year from a date, use the Year() function. To create a date
from a year, you can use the DateSerial() function, for example
DateSerial([YearField], 1, 1) will return a date corresponding to the first
of January in whatever year was contained in YearField. See 'Year function'
and 'DateSerial function' in the help files for details.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top