I'm about tomake alistofevents. I wantthe dateof the eventcompared tothe current date.If theeventdate has passedtoday,it shall notappear.
This is what I got so fare :-)
@{ var today = DateTime.Now; }
@for(var i =1; i < 5; i++) { var dateItem = @Model.GetPropertyValue("date" + i); <p>@today er i dag</p> if(dateItem < today){ <p>Write something here if date haven't passed today</p> }
@for(var i =1; i < 5; i++) { if(Model.HasValue("item" + i)){
var dateItem = @Model.GetPropertyValue("date" + i); var postDate = umbraco.library.FormatDateTime(dateItem.ToString(), "dd/MM/yyyy"); var tester = umbraco.library.DateGreaterThanOrEqualToday(@dateItem);
<p>I am @tester </p> <p>@Model.GetPropertyValue("item" + i) og @postDate</p>
}
}
I have someother itemsthat do not work, but Ithink it's bestif I createa new question
@for(var i =1; i < 5; i++)
{
var dateItem = CurrentModel.GetPropertyValue("date" + i).AsDateTime();
<p>@today er i dag</p>
if(dateItem < today){
<p>Write something here if date haven't passed today</p>
}
}
compare dates
Hi
I'm about to make a list of events.
I want the date of the event compared to the current date. If the event date has passed today, it shall not appear.
This is what I got so fare :-)
Hope you understand what I mean :-)
Hi Kate,
I'm pretty sure you are using a Mvc Partial View, but could you please confirm?
Also just to check you have 5 properties in your document type with alias like "date1", "date2" etc...?
Thanks,
Jeavon
Sorry, I have no idea what Mvc Partial View means :-(
The loop is working fine, so I dont think that is where the problem is. I think that it has something to do with the date format.
I have tryed to make at total simple exampel:
If I write
it works fine
but if i write
it gives me an error: Error loading MacroEngine script (file: loop.cshtml)
I got the date right
I have some other items that do not work, but I think it's best if I create a new question
Hi Kate,
I would approach it like this:
Jeavon
is working on a reply...