|
Prev: How do you embed a google map in access?
Next: How to Edit Records when some fields are "Many to 1" relationship
From: AJCB on 4 Jul 2008 06:09 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 4 Jul 2008 06:30 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 4 Jul 2008 06:37 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 4 Jul 2008 06:37 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 4 Jul 2008 07:07
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 |