I have a great display template that is working almost as expected. I now have a request to have the Due Date show RED once it is past due. I am still learning how to change things in the display template but for the most part it is working well.

How can I add the var to tell it if it is past due to change it to red. I am using regular date column in the list, and have a refinabledate managed property for the display template. I am only wanting the date and have ensured that the field is set to that.

I would appreciate any help. Dorinda

PS if anyone can help get the date display to work I would love that as well I would like it to be just mm/dd/yyyy but the time is still showing up and I cannot figure that out.

1 Answer 1


In this sample I check the revision date against current date . In the HTML section you can switch on the boolean and either display the date in red or black

code sample from Item Display template

  • I dont have a revision date to check against I just want it to check against todays date and if it is past that date due show as red. I am not sure how to implement this?
    – Dorinda
    Mar 22, 2019 at 18:06
  • Just substitute revision date with your due date. Mar 22, 2019 at 19:27
  • This is the same answer you gave me before and I couldnt get it to work. I am even starting from scratch and having issues.
    – Dorinda
    Mar 22, 2019 at 19:36
  • The refinabledate field contains the due date, right? So var duedate = $getItemValue(ctx, refinabledate XX) will allow you to compre duedate with today Mar 22, 2019 at 19:52
  • This is what I am showing in the display template and now it is not working at all var duedate = $getItemValue(ctx, "Refinabledate02") ; var ContentExpired = false; if(!$isEmptyString(revisiondate.inputValue)) { var thisdate = new Date(); var parseRevDate = new Date(revisiondate); revisiondate = parseRevDate.format('dd/MM/yyyy'); if(parseRevDate < thisdate) { ContentExpired = true; } }
    – Dorinda
    Mar 22, 2019 at 20:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.