G Guest Jan 12, 2006 #1 How can write a delete query to delete records in a table where the Date field formatted 1/15/04 is older than 1 yr. from today? Thanks
How can write a delete query to delete records in a table where the Date field formatted 1/15/04 is older than 1 yr. from today? Thanks
G Guest Jan 12, 2006 #2 Save your data first, there will be no return try this DELETE TableName.* FROM TableName WHERE TableName.DateFieldName<DateAdd("yyyy",-1,Date())
Save your data first, there will be no return try this DELETE TableName.* FROM TableName WHERE TableName.DateFieldName<DateAdd("yyyy",-1,Date())
J Jeff Boyce Jan 13, 2006 #3 "Why?" Why do you want to delete records older than 1 year? Is your database experiencing performance issues? Are you trying to create separate databases for each year? You've asked "how" to do something. Can you describe the underlying business need? Regards Jeff Boyce <Office/Access MVP>
"Why?" Why do you want to delete records older than 1 year? Is your database experiencing performance issues? Are you trying to create separate databases for each year? You've asked "how" to do something. Can you describe the underlying business need? Regards Jeff Boyce <Office/Access MVP>
J John Vinson Feb 4, 2006 #5 How about dates 15 days old? Click to expand... A criterion of < DateAdd("d", -15, Date()) will return all records where the datefield upon which you use the criterion is older than 15 days ago. And how about today's records? Click to expand... =Date() Open the VBA editor by typing Ctrl-G (to get to the proper Help file) and take a look at the online help for DateAdd and DateDiff. John W. Vinson[MVP]
How about dates 15 days old? Click to expand... A criterion of < DateAdd("d", -15, Date()) will return all records where the datefield upon which you use the criterion is older than 15 days ago. And how about today's records? Click to expand... =Date() Open the VBA editor by typing Ctrl-G (to get to the proper Help file) and take a look at the online help for DateAdd and DateDiff. John W. Vinson[MVP]