Add and remove days from date

This example shows how to minus 1 day from the current days date. This is used on line 4 where the variable is set to search the YOURSTRUCTURENAME structure based on the published Date where the date starts from the beginning of time to today-1.

You can revert as many days as you like (even get the info from a querystring). The function will also maintain the date structure and time (i.e. 27/01/1985 03:45:00).

  1. #set ($dateRevert = -1)  
  3. #set ($publishedDate = $date.format('yyyyMMdd',$UtilMethods.addDays($, $dateRevert)))  
  4. #set ($publishedDate = "+YOURSTRUCTURENAME.publishedDate:[0000000 TO $publishedDate]")  
  6. #set ($articleList = $dotcontent.pull("+structureName:YOURSTRUCTURENAME $!{publishedDate}","10",""))   

You could also use the following method.

  1. $date.format('MM/dd/yyyy', $content.endSeason)  
  2. #set($dateYear = $date.get('yyyy'))  
  3. #set($nextYear = $webapi.parseInt($dateYear) + 1)    //returns current year+1  
comments powered by Disqus