From: AJCB on
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
From: Allen Browne on
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(a)discussions.microsoft.com> wrote in message
news:7B61CF07-A879-4EF6-8AD2-1EFD317214E2(a)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

From: Dennis on
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
From: Dennis on
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
From: AJCB on
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