WUGNET, the Windows User Group Network
Your Complete Resource Center for "The Best" in Shareware, Computing Tips and Support, Windows Industry News... and much more!
Home Forums Shareware Windows Tips Hot Offers FREE Newsletters Arcade Contact Us About Partners
Search WUGNET: RSS Feeds RSS Feeds Advertise with WUGNET    |    Shareware eBooks
HomeHome FAQFAQ   SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log in/Register/PasswordLog in/Register/Password

Delete data more than 2 months old

 
   Home -> Office other -> General Discussions RSS
Next:  General Discussions: Report Formatting  
Author Message
AJCB

External


Since: Sep 20, 2007
Posts: 24



(Msg. 1) Posted: Fri Jul 04, 2008 3:09 am
Post subject: Delete data more than 2 months old Add to elertz
Archived from groups: microsoft>public>access (more info?)

Hi there.

I have a field in a table which shows the date and time that a record was
created in Access.

I am wanting to run a query that will automatically delete data that is more
than 2 months old, but I cannot figure out what string to put in the query.

Can anyone help me?

Regards
AJ
Back to top
Login to vote
Dennis

External


Since: Oct 19, 2004
Posts: 738



(Msg. 2) Posted: Fri Jul 04, 2008 3:37 am
Post subject: RE: Delete data more than 2 months old Add to elertz [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Oops sorry, the criteria should be <Now()

"AJCB" wrote:

> Hi there.
>
> I have a field in a table which shows the date and time that a record was
> created in Access.
>
> I am wanting to run a query that will automatically delete data that is more
> than 2 months old, but I cannot figure out what string to put in the query.
>
> Can anyone help me?
>
> Regards
> AJ
Back to top
Login to vote
Dennis

External


Since: Oct 19, 2004
Posts: 738



(Msg. 3) Posted: Fri Jul 04, 2008 3:37 am
Post subject: RE: Delete data more than 2 months old Add to elertz [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Create a query with your table as its source. Create a column in the query
like this
HowOld: DateAdd("m",2,[Date Created])
In the criteria fior this column put
>Now()
Check the query return the correct results and then change its type to a
delete query

"AJCB" wrote:

> Hi there.
>
> I have a field in a table which shows the date and time that a record was
> created in Access.
>
> I am wanting to run a query that will automatically delete data that is more
> than 2 months old, but I cannot figure out what string to put in the query.
>
> Can anyone help me?
>
> Regards
> AJ
Back to top
Login to vote
AJCB

External


Since: Sep 20, 2007
Posts: 24



(Msg. 4) Posted: Fri Jul 04, 2008 4:07 am
Post subject: RE: Delete data more than 2 months old Add to elertz [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Hi Dennis.

This did not work. I didn't get an error message, but all it put in the
field was the date and the time that the record was created.

Do you have any other ideas?

"Dennis" wrote:

> Create a query with your table as its source. Create a column in the query
> like this
> HowOld: DateAdd("m",2,[Date Created])
> In the criteria fior this column put
> >Now()
> Check the query return the correct results and then change its type to a
> delete query
>
> "AJCB" wrote:
>
> > Hi there.
> >
> > I have a field in a table which shows the date and time that a record was
> > created in Access.
> >
> > I am wanting to run a query that will automatically delete data that is more
> > than 2 months old, but I cannot figure out what string to put in the query.
> >
> > Can anyone help me?
> >
> > Regards
> > AJ
Back to top
Login to vote
Dennis

External


Since: Oct 19, 2004
Posts: 738



(Msg. 5) Posted: Fri Jul 04, 2008 4:28 am
Post subject: RE: Delete data more than 2 months old Add to elertz [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

It works OK but obviously I cannot see what you have done. Have you tried it
Allen's way instead ?

"AJCB" wrote:

> Hi Dennis.
>
> This did not work. I didn't get an error message, but all it put in the
> field was the date and the time that the record was created.
>
> Do you have any other ideas?
>
> "Dennis" wrote:
>
> > Create a query with your table as its source. Create a column in the query
> > like this
> > HowOld: DateAdd("m",2,[Date Created])
> > In the criteria fior this column put
> > >Now()
> > Check the query return the correct results and then change its type to a
> > delete query
> >
> > "AJCB" wrote:
> >
> > > Hi there.
> > >
> > > I have a field in a table which shows the date and time that a record was
> > > created in Access.
> > >
> > > I am wanting to run a query that will automatically delete data that is more
> > > than 2 months old, but I cannot figure out what string to put in the query.
> > >
> > > Can anyone help me?
> > >
> > > Regards
> > > AJ
Back to top
Login to vote
AJCB

External


Since: Sep 20, 2007
Posts: 24



(Msg. 6) Posted: Fri Jul 04, 2008 4:44 am
Post subject: RE: Delete data more than 2 months old Add to elertz [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

I will try, but I am not really that confident using SQL queries, as I
usually cannot get them to work.

"Dennis" wrote:

> It works OK but obviously I cannot see what you have done. Have you tried it
> Allen's way instead ?
>
> "AJCB" wrote:
>
> > Hi Dennis.
> >
> > This did not work. I didn't get an error message, but all it put in the
> > field was the date and the time that the record was created.
> >
> > Do you have any other ideas?
> >
> > "Dennis" wrote:
> >
> > > Create a query with your table as its source. Create a column in the query
> > > like this
> > > HowOld: DateAdd("m",2,[Date Created])
> > > In the criteria fior this column put
> > > >Now()
> > > Check the query return the correct results and then change its type to a
> > > delete query
> > >
> > > "AJCB" wrote:
> > >
> > > > Hi there.
> > > >
> > > > I have a field in a table which shows the date and time that a record was
> > > > created in Access.
> > > >
> > > > I am wanting to run a query that will automatically delete data that is more
> > > > than 2 months old, but I cannot figure out what string to put in the query.
> > > >
> > > > Can anyone help me?
> > > >
> > > > Regards
> > > > AJ
Back to top
Login to vote
John W. Vinson

External


Since: Jan 29, 2004
Posts: 5528



(Msg. 7) Posted: Fri Jul 04, 2008 3:42 pm
Post subject: Re: Delete data more than 2 months old Add to elertz [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Fri, 4 Jul 2008 03:09:01 -0700, AJCB <AJCB DeleteThis @discussions.microsoft.com>
wrote:

>I am wanting to run a query that will automatically delete data that is more
>than 2 months old,

Why?

You'll NEVER need to see historical data?

Bear in mind that deleting data will NOT free up space in your database (until
you Compact), and if you have suitable indexes, won't much affect the speed of
your queries, unless you have hundreds of thousands of records.

>but I cannot figure out what string to put in the query.

< DateAdd("m", 2, Date())

will delete all records older than two months ago today. BACK UP YOUR DATABASE
first.
--

John W. Vinson [MVP]
Back to top
Login to vote
Allen Browne

External


Since: Nov 08, 2003
Posts: 9138



(Msg. 8) Posted: Fri Jul 04, 2008 6:30 pm
Post subject: Re: Delete data more than 2 months old Add to elertz [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

DELETE FROM [YourTableNameHere]
WHERE [YourDateTimeFieldHere] < DateAdd("m", -2, Date());

--
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.

"AJCB" <AJCB.DeleteThis@discussions.microsoft.com> wrote in message
news:7B61CF07-A879-4EF6-8AD2-1EFD317214E2@microsoft.com...
> Hi there.
>
> I have a field in a table which shows the date and time that a record was
> created in Access.
>
> I am wanting to run a query that will automatically delete data that is
> more
> than 2 months old, but I cannot figure out what string to put in the
> query.
>
> Can anyone help me?
>
> Regards
> AJ
Back to top
Login to vote
Display posts from previous:   
       Home -> Office other -> General Discussions All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Categories:
 Windows XP
 Windows Vista
 Windows Other
 Office
  Office Other
 Security
 WinRAR
  • Home |
  • Shareware |
  • Windows Tips |
  • Hot Offers |
  • FREE Newsletters |
  • Arcade |
  • Forums |
  • eBooks |
  • About WUGNET |
  • Partners |
  • Contact

  • WUGNET Privacy Policy |
  • Link to WUGNET