A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Changing a field



 
 
Thread Tools Display Modes
  #1  
Old July 17th, 2008, 02:20 PM posted to microsoft.public.access.tablesdbdesign
C Tate
external usenet poster
 
Posts: 45
Default Changing a field

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.
  #2  
Old July 17th, 2008, 02:22 PM posted to microsoft.public.access.tablesdbdesign
Ryan
external usenet poster
 
Posts: 551
Default Changing a field

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


"C Tate" wrote:

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.

  #3  
Old July 17th, 2008, 02:41 PM posted to microsoft.public.access.tablesdbdesign
C Tate
external usenet poster
 
Posts: 45
Default Changing a field

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" wrote:

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


"C Tate" wrote:

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.

  #4  
Old July 17th, 2008, 02:52 PM posted to microsoft.public.access.tablesdbdesign
Allen Browne
external usenet poster
 
Posts: 11,706
Default Changing a field

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
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"C Tate" wrote in message
...
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.


  #5  
Old July 17th, 2008, 02:54 PM posted to microsoft.public.access.tablesdbdesign
Ryan
external usenet poster
 
Posts: 551
Default Changing a field

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" wrote:

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" wrote:

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


"C Tate" wrote:

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.

  #6  
Old July 18th, 2008, 11:14 AM posted to microsoft.public.access.tablesdbdesign
C Tate
external usenet poster
 
Posts: 45
Default Changing a field

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

"Allen Browne" wrote:

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
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"C Tate" wrote in message
...
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.



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:40 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.