Change comment:
added "older than 3 days".
Summary
-
Page properties (2 modified, 0 added, 0 removed)
Details
- Page properties
-
- Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. DaniloOliveira1 +XWiki.polx - Content
-
... ... @@ -54,6 +54,20 @@ 54 54 #set($hql = "where year(doc.date) = year(current_date()) and month(doc.date) = month(current_date()) and day(doc.date) = day(current_date()) and hour(doc.date) > (hour(current_time()) - 1) order by doc.date desc") 55 55 {{/code}} 56 56 57 + 58 +=== Query documents older than 3 days === 59 + 60 +The following snippet deletes all documents in the space TempDocs that are older than 3 days. 61 +For the computation of the relative age, a calendar object created by the $datetool is used and passed to the hibernate query. Tested with MySQL only. 62 + 63 +{{code language="none"}} 64 +#set($hql="select doc.fullName from XWikiDocument as doc where doc.web = ? and doc.creationDate < ? ") 65 +#set($cal = $datetool.systemCalendar)$cal.add(7,-3) 66 +#set($olderTempDocs=$xwiki.search($hql,5000, 0, ["TempdDocs",$datetool.toDate($cal)])) 67 +#foreach($x in $olderTempDocs)$xwiki.getDocument($x).deleteWithProgrammingRights()#end 68 +{{/code}} 69 + 70 + 57 57 Other examples: 58 58 59 59 * Listing all documents modified during the current day: {{code language="none"}}where year(doc.date) = year(current_date()) and month(doc.date) = month(current_date()) and day(doc.date) > (day(current_date()) - 1) order by doc.date desc{{/code}}