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 » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Year Minus One



 
 
Thread Tools Display Modes
  #1  
Old December 1st, 2009, 03:32 PM posted to microsoft.public.access.queries
ann
external usenet poster
 
Posts: 462
Default Year Minus One

I am using Access 2002 and have a two character text field [txtDRSYear] that
holds the last to characters of the current year, (example 09). I want to
retrieve all the records for the current year minus one so I can archive all
the 2009 data in 2010 but I can't figure out how to do that using Date().
Thanks in advance.
  #2  
Old December 1st, 2009, 03:51 PM posted to microsoft.public.access.queries
Jeff Boyce
external usenet poster
 
Posts: 1,555
Default Year Minus One

Ann

Here's a couple of observations you may wish to consider before
proceeding...

If you are storing text holding the last two digits of a year, why? Why in
text (if you'll be 'doing math', and why just two? Access offers extensive
date/time functions, but you'd need to store an actual date. Is there a
chance your table's records could benefit from having an actual date (or
date + time)?

Second, folks use "archive" in differing ways. Are you proposing to remove
records from a table and put them somewhere else? If so, why?! If you have
a field on that table that is, say, [DateArchived], into which you store a
date (or date/time) value when the record is ready for 'archiving', then you
keep all your data in one table, but use queries to only show the records
that are not archived in your every day application. When it comes time to
look historically, look at them all.

JOPO (just one person's opinions)

--

Regards

Jeff Boyce
Microsoft Access MVP

Disclaimer: This author may have received products and services mentioned in
this post. Mention and/or description of a product or service herein does
not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.


"Ann" wrote in message
...
I am using Access 2002 and have a two character text field [txtDRSYear]
that
holds the last to characters of the current year, (example 09). I want to
retrieve all the records for the current year minus one so I can archive
all
the 2009 data in 2010 but I can't figure out how to do that using Date().
Thanks in advance.



  #3  
Old December 1st, 2009, 03:51 PM posted to microsoft.public.access.queries
Jeff Boyce
external usenet poster
 
Posts: 1,555
Default Year Minus One

Ann

Here's a couple of observations you may wish to consider before
proceeding...

If you are storing text holding the last two digits of a year, why? Why in
text (if you'll be 'doing math', and why just two? Access offers extensive
date/time functions, but you'd need to store an actual date. Is there a
chance your table's records could benefit from having an actual date (or
date + time)?

Second, folks use "archive" in differing ways. Are you proposing to remove
records from a table and put them somewhere else? If so, why?! If you have
a field on that table that is, say, [DateArchived], into which you store a
date (or date/time) value when the record is ready for 'archiving', then you
keep all your data in one table, but use queries to only show the records
that are not archived in your every day application. When it comes time to
look historically, look at them all.

JOPO (just one person's opinions)

--

Regards

Jeff Boyce
Microsoft Access MVP

Disclaimer: This author may have received products and services mentioned in
this post. Mention and/or description of a product or service herein does
not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.


"Ann" wrote in message
...
I am using Access 2002 and have a two character text field [txtDRSYear]
that
holds the last to characters of the current year, (example 09). I want to
retrieve all the records for the current year minus one so I can archive
all
the 2009 data in 2010 but I can't figure out how to do that using Date().
Thanks in advance.



  #4  
Old December 1st, 2009, 03:51 PM posted to microsoft.public.access.queries
Jeff Boyce
external usenet poster
 
Posts: 1,555
Default Year Minus One

Ann

Here's a couple of observations you may wish to consider before
proceeding...

If you are storing text holding the last two digits of a year, why? Why in
text (if you'll be 'doing math', and why just two? Access offers extensive
date/time functions, but you'd need to store an actual date. Is there a
chance your table's records could benefit from having an actual date (or
date + time)?

Second, folks use "archive" in differing ways. Are you proposing to remove
records from a table and put them somewhere else? If so, why?! If you have
a field on that table that is, say, [DateArchived], into which you store a
date (or date/time) value when the record is ready for 'archiving', then you
keep all your data in one table, but use queries to only show the records
that are not archived in your every day application. When it comes time to
look historically, look at them all.

JOPO (just one person's opinions)

--

Regards

Jeff Boyce
Microsoft Access MVP

Disclaimer: This author may have received products and services mentioned in
this post. Mention and/or description of a product or service herein does
not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.


"Ann" wrote in message
...
I am using Access 2002 and have a two character text field [txtDRSYear]
that
holds the last to characters of the current year, (example 09). I want to
retrieve all the records for the current year minus one so I can archive
all
the 2009 data in 2010 but I can't figure out how to do that using Date().
Thanks in advance.



  #5  
Old December 1st, 2009, 04:16 PM posted to microsoft.public.access.queries
Jerry Whittle
external usenet poster
 
Posts: 4,732
Default Year Minus One

First off, unless you have many thousands of records, archiving records to
another table or database is usually a bad idea. Other than getting near the
2 GB file limit, I wouldn't recommend doing it.

As [txtDRSYear] is a text field, Date won't work on it by itself. Something
like below as the criteria of a query will work. It subtract a year from the
current Date. Then it uses the Format function to extract the last two
characters of the year and coverts it to a string. For example today it
returns 08 .

Format(DateAdd("yyyy",-1,Date()),"yy")
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.

"Ann" wrote:

I am using Access 2002 and have a two character text field [txtDRSYear] that
holds the last to characters of the current year, (example 09). I want to
retrieve all the records for the current year minus one so I can archive all
the 2009 data in 2010 but I can't figure out how to do that using Date().
Thanks in advance.

  #6  
Old December 1st, 2009, 04:16 PM posted to microsoft.public.access.queries
Jerry Whittle
external usenet poster
 
Posts: 4,732
Default Year Minus One

First off, unless you have many thousands of records, archiving records to
another table or database is usually a bad idea. Other than getting near the
2 GB file limit, I wouldn't recommend doing it.

As [txtDRSYear] is a text field, Date won't work on it by itself. Something
like below as the criteria of a query will work. It subtract a year from the
current Date. Then it uses the Format function to extract the last two
characters of the year and coverts it to a string. For example today it
returns 08 .

Format(DateAdd("yyyy",-1,Date()),"yy")
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.

"Ann" wrote:

I am using Access 2002 and have a two character text field [txtDRSYear] that
holds the last to characters of the current year, (example 09). I want to
retrieve all the records for the current year minus one so I can archive all
the 2009 data in 2010 but I can't figure out how to do that using Date().
Thanks in advance.

  #7  
Old December 1st, 2009, 04:16 PM posted to microsoft.public.access.queries
Jerry Whittle
external usenet poster
 
Posts: 4,732
Default Year Minus One

First off, unless you have many thousands of records, archiving records to
another table or database is usually a bad idea. Other than getting near the
2 GB file limit, I wouldn't recommend doing it.

As [txtDRSYear] is a text field, Date won't work on it by itself. Something
like below as the criteria of a query will work. It subtract a year from the
current Date. Then it uses the Format function to extract the last two
characters of the year and coverts it to a string. For example today it
returns 08 .

Format(DateAdd("yyyy",-1,Date()),"yy")
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.

"Ann" wrote:

I am using Access 2002 and have a two character text field [txtDRSYear] that
holds the last to characters of the current year, (example 09). I want to
retrieve all the records for the current year minus one so I can archive all
the 2009 data in 2010 but I can't figure out how to do that using Date().
Thanks in advance.

  #8  
Old December 2nd, 2009, 05:11 PM posted to microsoft.public.access.queries
ann
external usenet poster
 
Posts: 462
Default Year Minus One

Hi Jeff,

The two character field is part of a three field DRS number that consists of
the month, year and DRS number that the customer uses to track their records.
I thought that would be easier to use to archive the data. I did intend to
move the data to a new table so the existing tables only had current years
information but the idea of adding an archived date sounds good too.

I would still want it to happen at the press of a button though and the code
Jerry gave me would do that. I do have one question though. The first table
has a one to many relationship with a second table and the second table has a
one to many relationship with a third table. At this point I don't use the
second or third tables by themselves so is it OK to just have the Archive
Date on the first table or should this date also be a field in the second and
third table too? Thanks for the help.

"Jeff Boyce" wrote:

Ann

Here's a couple of observations you may wish to consider before
proceeding...

If you are storing text holding the last two digits of a year, why? Why in
text (if you'll be 'doing math', and why just two? Access offers extensive
date/time functions, but you'd need to store an actual date. Is there a
chance your table's records could benefit from having an actual date (or
date + time)?

Second, folks use "archive" in differing ways. Are you proposing to remove
records from a table and put them somewhere else? If so, why?! If you have
a field on that table that is, say, [DateArchived], into which you store a
date (or date/time) value when the record is ready for 'archiving', then you
keep all your data in one table, but use queries to only show the records
that are not archived in your every day application. When it comes time to
look historically, look at them all.

JOPO (just one person's opinions)

--

Regards

Jeff Boyce
Microsoft Access MVP

Disclaimer: This author may have received products and services mentioned in
this post. Mention and/or description of a product or service herein does
not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.


"Ann" wrote in message
...
I am using Access 2002 and have a two character text field [txtDRSYear]
that
holds the last to characters of the current year, (example 09). I want to
retrieve all the records for the current year minus one so I can archive
all
the 2009 data in 2010 but I can't figure out how to do that using Date().
Thanks in advance.



.

  #9  
Old December 2nd, 2009, 05:11 PM posted to microsoft.public.access.queries
ann
external usenet poster
 
Posts: 462
Default Year Minus One

Hi Jeff,

The two character field is part of a three field DRS number that consists of
the month, year and DRS number that the customer uses to track their records.
I thought that would be easier to use to archive the data. I did intend to
move the data to a new table so the existing tables only had current years
information but the idea of adding an archived date sounds good too.

I would still want it to happen at the press of a button though and the code
Jerry gave me would do that. I do have one question though. The first table
has a one to many relationship with a second table and the second table has a
one to many relationship with a third table. At this point I don't use the
second or third tables by themselves so is it OK to just have the Archive
Date on the first table or should this date also be a field in the second and
third table too? Thanks for the help.

"Jeff Boyce" wrote:

Ann

Here's a couple of observations you may wish to consider before
proceeding...

If you are storing text holding the last two digits of a year, why? Why in
text (if you'll be 'doing math', and why just two? Access offers extensive
date/time functions, but you'd need to store an actual date. Is there a
chance your table's records could benefit from having an actual date (or
date + time)?

Second, folks use "archive" in differing ways. Are you proposing to remove
records from a table and put them somewhere else? If so, why?! If you have
a field on that table that is, say, [DateArchived], into which you store a
date (or date/time) value when the record is ready for 'archiving', then you
keep all your data in one table, but use queries to only show the records
that are not archived in your every day application. When it comes time to
look historically, look at them all.

JOPO (just one person's opinions)

--

Regards

Jeff Boyce
Microsoft Access MVP

Disclaimer: This author may have received products and services mentioned in
this post. Mention and/or description of a product or service herein does
not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.


"Ann" wrote in message
...
I am using Access 2002 and have a two character text field [txtDRSYear]
that
holds the last to characters of the current year, (example 09). I want to
retrieve all the records for the current year minus one so I can archive
all
the 2009 data in 2010 but I can't figure out how to do that using Date().
Thanks in advance.



.

  #10  
Old December 2nd, 2009, 05:11 PM posted to microsoft.public.access.queries
ann
external usenet poster
 
Posts: 462
Default Year Minus One

Hi Jeff,

The two character field is part of a three field DRS number that consists of
the month, year and DRS number that the customer uses to track their records.
I thought that would be easier to use to archive the data. I did intend to
move the data to a new table so the existing tables only had current years
information but the idea of adding an archived date sounds good too.

I would still want it to happen at the press of a button though and the code
Jerry gave me would do that. I do have one question though. The first table
has a one to many relationship with a second table and the second table has a
one to many relationship with a third table. At this point I don't use the
second or third tables by themselves so is it OK to just have the Archive
Date on the first table or should this date also be a field in the second and
third table too? Thanks for the help.

"Jeff Boyce" wrote:

Ann

Here's a couple of observations you may wish to consider before
proceeding...

If you are storing text holding the last two digits of a year, why? Why in
text (if you'll be 'doing math', and why just two? Access offers extensive
date/time functions, but you'd need to store an actual date. Is there a
chance your table's records could benefit from having an actual date (or
date + time)?

Second, folks use "archive" in differing ways. Are you proposing to remove
records from a table and put them somewhere else? If so, why?! If you have
a field on that table that is, say, [DateArchived], into which you store a
date (or date/time) value when the record is ready for 'archiving', then you
keep all your data in one table, but use queries to only show the records
that are not archived in your every day application. When it comes time to
look historically, look at them all.

JOPO (just one person's opinions)

--

Regards

Jeff Boyce
Microsoft Access MVP

Disclaimer: This author may have received products and services mentioned in
this post. Mention and/or description of a product or service herein does
not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.


"Ann" wrote in message
...
I am using Access 2002 and have a two character text field [txtDRSYear]
that
holds the last to characters of the current year, (example 09). I want to
retrieve all the records for the current year minus one so I can archive
all
the 2009 data in 2010 but I can't figure out how to do that using Date().
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 10:04 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.