DatePart function

K

KyBoy1976

I'm trying to utilize the "DatePart" function to populate a field in my table
to only show the "Year" of my incident which is filled in using a form.

I currently have a "Recieved_Date" field that is filled in using a form, and
I want the DatePart to take only the year from that information.

Year: DatePart("yyyy",[Recieved_Date])

that function gives me an error, and I'm not certain why.
 
S

Stuart McCall

KyBoy1976 said:
I'm trying to utilize the "DatePart" function to populate a field in my
table
to only show the "Year" of my incident which is filled in using a form.

I currently have a "Recieved_Date" field that is filled in using a form,
and
I want the DatePart to take only the year from that information.

Year: DatePart("yyyy",[Recieved_Date])

that function gives me an error, and I'm not certain why.

The word 'Year' is reserved in Access (its the name of a built-in function.
Try calling it RecvDate instead.
 
D

Douglas J. Steele

What's the error?

One thing you need do is rename your alias: Year is a reserved word, and you
shouldn't use reserved words for your own purposes. For a comprehensive list
of names to avoid (as well as a link to a free utility to check your
application for compliance), check what Allen Browne has at
http://www.allenbrowne.com/AppIssueBadWord.html
 
K

KyBoy1976

TY for the responses, i realize "year" is a reserved word, and I could have
worded my issue a bit better.

My actual field in my table to be populated is YR_Made, access tells you
that year is a reserved word and shouldn't be used.

However, the datepart function still does not function as i need it to.

Douglas J. Steele said:
What's the error?

One thing you need do is rename your alias: Year is a reserved word, and you
shouldn't use reserved words for your own purposes. For a comprehensive list
of names to avoid (as well as a link to a free utility to check your
application for compliance), check what Allen Browne has at
http://www.allenbrowne.com/AppIssueBadWord.html

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


KyBoy1976 said:
I'm trying to utilize the "DatePart" function to populate a field in my
table
to only show the "Year" of my incident which is filled in using a form.

I currently have a "Recieved_Date" field that is filled in using a form,
and
I want the DatePart to take only the year from that information.

Year: DatePart("yyyy",[Recieved_Date])

that function gives me an error, and I'm not certain why.


.
 
K

KARL DEWEY

I think you will find that DatePart removes any time fraction leaving only
the DatePart.

Try Year([YR_Made])

--
Build a little, test a little.


KyBoy1976 said:
TY for the responses, i realize "year" is a reserved word, and I could have
worded my issue a bit better.

My actual field in my table to be populated is YR_Made, access tells you
that year is a reserved word and shouldn't be used.

However, the datepart function still does not function as i need it to.

Douglas J. Steele said:
What's the error?

One thing you need do is rename your alias: Year is a reserved word, and you
shouldn't use reserved words for your own purposes. For a comprehensive list
of names to avoid (as well as a link to a free utility to check your
application for compliance), check what Allen Browne has at
http://www.allenbrowne.com/AppIssueBadWord.html

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


KyBoy1976 said:
I'm trying to utilize the "DatePart" function to populate a field in my
table
to only show the "Year" of my incident which is filled in using a form.

I currently have a "Recieved_Date" field that is filled in using a form,
and
I want the DatePart to take only the year from that information.

Year: DatePart("yyyy",[Recieved_Date])

that function gives me an error, and I'm not certain why.


.
 

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