Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Greg McMullen 49 posts 195 karma points
    Feb 21, 2013 @ 15:34
    Greg McMullen
    0

    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

  • Andreas Iseli 150 posts 427 karma points
    Feb 21, 2013 @ 16:58
    Andreas Iseli
    100

    Normally you should be fine with the DateTime standards.

    var endDate = createdDate.AddDays(30).

    Or has the CreateTime another type?

  • Greg McMullen 49 posts 195 karma points
    Feb 21, 2013 @ 17:38
    Greg McMullen
    0

    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!

Please Sign in or register to post replies

Write your reply to:

Draft