I'm working on a small script to "retire" featured articles after a particular date. I found "DateAdd" which seems like a great way to accomplish what I'm wanting to do. However, I cannot seem to get it to work the way I thought I could.
Here's the code, inside of a foreach loop:
var image = "";
var createdDate = item.CreateDate;
var endDate = umbraco.library.DateAdd(@createdDate,"d",30);
if ( umbraco.library.CurrentDate() > endDate ){
STORY CODE HERE
}
The code saves, but it fails when visiting the page. The usual "Error loading MacroEngine script."
Ideally, I would like a drop down parameter for the integer input (all days) 7 - 14 - 30 - 60 - 90, but I would like to get it to work with the "CreateDate" first.
I have also tried using item.CreateDate inside of the DateAdd().
Using Date Add for publication "retirement."
I'm working on a small script to "retire" featured articles after a particular date. I found "DateAdd" which seems like a great way to accomplish what I'm wanting to do. However, I cannot seem to get it to work the way I thought I could.
Here's the code, inside of a foreach loop:
var image = ""; var createdDate = item.CreateDate; var endDate = umbraco.library.DateAdd(@createdDate,"d",30); if ( umbraco.library.CurrentDate() > endDate ){ STORY CODE HERE }
The code saves, but it fails when visiting the page. The usual "Error loading MacroEngine script."
Ideally, I would like a drop down parameter for the integer input (all days) 7 - 14 - 30 - 60 - 90, but I would like to get it to work with the "CreateDate" first.
I have also tried using item.CreateDate inside of the DateAdd().
Any direction would be appreciated. Thanks,
Greg
Normally you should be fine with the DateTime standards.
var endDate = createdDate.AddDays(30).
Or has the CreateTime another type?
Thanks Andreas, that seems to work. Now I'm having other issues (ordering, not pulling all the articles) but at least this portion works!
Thanks!
is working on a reply...