Custom date to show year only

G

Gill Webster

I've tried to follow the "Help" on customised date format, as I want to show just a year
of publication (4 digits) in my booklist.
I've tried "yyyy" without success - just get the usual unhelpful error message that the
"value is not valid for the field"

Anyone help a novice please?

--

Gill W

Life is not a rehearsal.
Take time out to smell the flowers & enjoy the sunset

(replies to Group only please)
 
C

Cheryl Fischer

Gill,

Presuming that the actual DataType in your table is "Date", you can use the
Year() function in a query or report as follows:

In a Query: PubYear: Year(PubDate)

In a Report: Put a TextBox on the report. Then in the ControlSource
property of that textbox, insert:

=Year(PubDate)

hth,
 
G

Gill Webster

Thanks Cheryl, but I really don't want anything this complicated. I just want to add the
year as data in the table for information, but I don't have/need a "full" date with days &
months. All I want is one column that I can put, say "1982" as year of publication.

My field is set to Date/Time, but it seems to need days & months as well as the year.

--

Gill W

Life is not a rehearsal.
Take time out to smell the flowers & enjoy the sunset

(replies to Group only please)
 
D

Douglas J. Steele

I'm assuming it's a Date field you're trying to format. Where are you
putting "yyyy"?

If it's in the Format property of a text box (or of a table field), all you
need is yyyy, with no quotes.
 
D

Douglas J. Steele

If you're using a Date field, you must have a complete date in it. This is
because of how dates are stored: they're 8 byte floating point numbers,
where the integer part represents the date as the number of days relative to
30 Dec, 1899 (and the decimal part represents the time as a fraction of a
day).

If all you want is the year, store it as an integer.
 
C

Cheryl Fischer

Yes, Gill, a Date/Time field requires a full date to be entered. If all you
want is to enter a Number representing a year of publication, change the
DataType to Number and the FieldSize to Integer.
 
G

Gill Webster

Thanks everybody for your helpful suggestions. I've taken the easy way and used "number" -
Long Integer. Seems to be working fine for what I need.

Thanks again,

--

Gill W

Life is not a rehearsal.
Take time out to smell the flowers & enjoy the sunset

(replies to Group only please)
 

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

Top