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. |
|
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|