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  

Year()



 
 
Thread Tools Display Modes
  #1  
Old May 10th, 2009, 11:18 PM posted to microsoft.public.access.tablesdbdesign
mike
external usenet poster
 
Posts: 3,942
Default Year()

I know how to extract the year from a date field in a form or query using the
Year function. But how would I do that in a table? I need to keep the year as
a field in the table. If I can't do it directly in a table, can I create an
expression in a form or query, then use the result to update a field named
Year in the table?

Thanks in advance for the advice!
  #2  
Old May 10th, 2009, 11:35 PM posted to microsoft.public.access.tablesdbdesign
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Year()

On Sun, 10 May 2009 15:18:58 -0700, Mike
wrote:

I know how to extract the year from a date field in a form or query using the
Year function. But how would I do that in a table? I need to keep the year as
a field in the table. If I can't do it directly in a table, can I create an
expression in a form or query, then use the result to update a field named
Year in the table?

Thanks in advance for the advice!


If you have the date in the table, then you do NOT need to - nor should you -
store the year. If you JUST want to store the year (and no date) then you
could just use an Integer or Long Integer number field - 2009 is a perfectly
valid number, after all. But if you have a date field #5/10/2009# then you can
use a query calculating the year as needed.

If you have both the year field AND the date field, then there'd be nothing to
prevent discrepancies, e.g. having #5/10/2009# in the date field and 1836 in
the year field!
--

John W. Vinson [MVP]
  #3  
Old May 11th, 2009, 12:12 AM posted to microsoft.public.access.tablesdbdesign
mike
external usenet poster
 
Posts: 3,942
Default Year()

Hi John:

I wanted to store the year in order for the client to use Filter by Form
using just the year rather than using greater than or equal to Jan 1 and less
than and equal to Dec 31. That was the request from the client.

Mike

"John W. Vinson" wrote:

On Sun, 10 May 2009 15:18:58 -0700, Mike
wrote:

I know how to extract the year from a date field in a form or query using the
Year function. But how would I do that in a table? I need to keep the year as
a field in the table. If I can't do it directly in a table, can I create an
expression in a form or query, then use the result to update a field named
Year in the table?

Thanks in advance for the advice!


If you have the date in the table, then you do NOT need to - nor should you -
store the year. If you JUST want to store the year (and no date) then you
could just use an Integer or Long Integer number field - 2009 is a perfectly
valid number, after all. But if you have a date field #5/10/2009# then you can
use a query calculating the year as needed.

If you have both the year field AND the date field, then there'd be nothing to
prevent discrepancies, e.g. having #5/10/2009# in the date field and 1836 in
the year field!
--

John W. Vinson [MVP]

  #4  
Old May 11th, 2009, 02:03 AM posted to microsoft.public.access.tablesdbdesign
Graham Mandeno
external usenet poster
 
Posts: 593
Default Year()

Hi Mike

There is still no need to *store* the year. Just include it as a calculated
field in the recordsource of your form.

OrderYear: Year([OrderDate]

(If your form is using the table directly as a RecordSource, then create a
query with all the required fields (including this calculated one) and bind
your form to the query instead.)

--
Good Luck :-)

Graham Mandeno [Access MVP]
Auckland, New Zealand

"Mike" wrote in message
...
Hi John:

I wanted to store the year in order for the client to use Filter by Form
using just the year rather than using greater than or equal to Jan 1 and
less
than and equal to Dec 31. That was the request from the client.

Mike

"John W. Vinson" wrote:

On Sun, 10 May 2009 15:18:58 -0700, Mike
wrote:

I know how to extract the year from a date field in a form or query
using the
Year function. But how would I do that in a table? I need to keep the
year as
a field in the table. If I can't do it directly in a table, can I create
an
expression in a form or query, then use the result to update a field
named
Year in the table?

Thanks in advance for the advice!


If you have the date in the table, then you do NOT need to - nor should
you -
store the year. If you JUST want to store the year (and no date) then you
could just use an Integer or Long Integer number field - 2009 is a
perfectly
valid number, after all. But if you have a date field #5/10/2009# then
you can
use a query calculating the year as needed.

If you have both the year field AND the date field, then there'd be
nothing to
prevent discrepancies, e.g. having #5/10/2009# in the date field and 1836
in
the year field!
--

John W. Vinson [MVP]



 




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 10:11 AM.


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