Changing a field

C

C Tate

I need to change a field from a date format to year only. So instead of it
reading 1 Apr 2008 or something similar it now only contains the year, ie,
2008. I'm sure this is a ridiculously easy thing to do but not sure how to go
about it as the field is already populated with data too. However, they are
no longer interested in the day or month!

Thanks in advance.
 
C

C Tate

I am not sure I understand properly. Does this mean we will still have to
enter a day and month? Because we don't want to do that. We now only want to
enter a year. Also, I am not exactly sure where/how I should enter this
statement you have given me.

Ryan said:
YearOnly:Format$([YourDateField],"yyyy")
--
Please remember to mark this post as answered if this solves your problem.


C Tate said:
I need to change a field from a date format to year only. So instead of it
reading 1 Apr 2008 or something similar it now only contains the year, ie,
2008. I'm sure this is a ridiculously easy thing to do but not sure how to go
about it as the field is already populated with data too. However, they are
no longer interested in the day or month!

Thanks in advance.
 
A

Allen Browne

1. Open your table in deisgn view.

2. Add a new field of type Number.
Give it a name such as InvoiceYear or TheYear - not just 'Year' because
Access will get confused by a VBA function that has that name.

3. Save the change to the table, and close it.

4. Create a new query that uses this table.
Change it to an update query (Update on Query menu.)
Access adds an Update row to the query design grid.

5. In the Update row under the near year field, enter:
Year([F1])
using your old date/time field name instead of F1.

6. Run the query.
Verify the new field has the correct numbers.
Close the query. (No need to save.)

7. Open the table in design view again.
Delete the old date/time field.
 
R

Ryan

If your going to change from a date field, to a simple year field, all I
would do is add another field in your table, and make it a text datatype. As
for the statement, you would put that in a blank field of a query. The
statement I gave you converts what you have already entered as mm/dd/yyyy to
just show the year, but if all your going to do is type a year, just add a
new field to your table of text data type.
--
Please remember to mark this post as answered if this solves your problem.


C Tate said:
I am not sure I understand properly. Does this mean we will still have to
enter a day and month? Because we don't want to do that. We now only want to
enter a year. Also, I am not exactly sure where/how I should enter this
statement you have given me.

Ryan said:
YearOnly:Format$([YourDateField],"yyyy")
--
Please remember to mark this post as answered if this solves your problem.


C Tate said:
I need to change a field from a date format to year only. So instead of it
reading 1 Apr 2008 or something similar it now only contains the year, ie,
2008. I'm sure this is a ridiculously easy thing to do but not sure how to go
about it as the field is already populated with data too. However, they are
no longer interested in the day or month!

Thanks in advance.
 
C

C Tate

Many thanks for an extremely clear and helpful reply. Most grateful.

Allen Browne said:
1. Open your table in deisgn view.

2. Add a new field of type Number.
Give it a name such as InvoiceYear or TheYear - not just 'Year' because
Access will get confused by a VBA function that has that name.

3. Save the change to the table, and close it.

4. Create a new query that uses this table.
Change it to an update query (Update on Query menu.)
Access adds an Update row to the query design grid.

5. In the Update row under the near year field, enter:
Year([F1])
using your old date/time field name instead of F1.

6. Run the query.
Verify the new field has the correct numbers.
Close the query. (No need to save.)

7. Open the table in design view again.
Delete the old date/time field.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

C Tate said:
I need to change a field from a date format to year only. So instead of it
reading 1 Apr 2008 or something similar it now only contains the year, ie,
2008. I'm sure this is a ridiculously easy thing to do but not sure how to
go
about it as the field is already populated with data too. However, they
are
no longer interested in the day or month!

Thanks in advance.
 

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