Hi, Wayne. Afaik, macro parameters don't support datetime directly, so your datetime picker is most probably converted to some other type. What data type do you use for your macro parameter?
whenever I access the dateTime property (which is a date picker with time, I get
Error loading Razor Script test.cshtml '.' or '(' expected
if I try and convert it (which I know it already is a DateTime data type) or use it directly it fails with this error. thats is only if I access it within the Where method
Ah, I understand. Your "date" is of the DateTime type and your "dateTime" is a datetime picker, right? So, actually the "dateTime" is a string that's actually a datetime formatted in a sortable "s" format (yyyy-MM-ddThh:mm). Your just need vice versa convert the "date" to a string with the sortable format too:
Hello. This post helped me a lot and it worked perfectly. Thank you very much!
I created a docType called 'Evento' with a custom property called 'data' and it is formatted with date and time. I need to get "today's" events even if your time is in the past. Could someone help me change the code below to make it work?
(forgive my bad English. I'm Brazilian)
var startNodeID = Parameter.nodeId; var father = Library.NodeById(startNodeID); // Get all descendants of type EVENTO:
Razor, .Where (DatetTime Greater Than Or Equal DateX )
Hello Folks.
I've been messing quite alot with this problem.
I can get this to work...
But what i really want is to find all child nodes where my DateTime Property is Greater Or Equal (>=) to a specific date.
Tried the following, and much more...
Seems logic to me, but gets me this: The binary operator GreaterThanOrEqual is not defined for the types 'System.Object' and 'System.Object'.
The Property is a "Date Picker with time", and of Database Type "Date", this can be changed if theres no solution with these.
Hope you can give me a hint / solution :)
Best Regards. Victor
Try:
.Where("dateAndTime > DateTime.Parse(\"11/10/2011\")")
hmm.. didn't work. just returns zero results, but no errors..
What if to try:
Nice! That worked.
Actually also got Jon's way to work as well.
Here's the to solutions i got running:
Thanks
Hi,
Thanks for finding the solution to my issue.
Although I use the following code, which is basically the same above, (dateTime being a date picker with time)
DateTime date = DateTime.Now;
dynamic Children = @item.Children.Where("active").Where("dateTime >= @0", date);
I get this error
Error loading Razor Script test.cshtml '.' or '(' expected
Which certainly related to the date picker property evaluation, as if I remove it and put .Where("@0 >= @0", date) for exapmle no script error occurs.
Any ideas, anyone ?
This is on 4.7.0 by the way.
Hi, Wayne. Afaik, macro parameters don't support datetime directly, so your datetime picker is most probably converted to some other type. What data type do you use for your macro parameter?
Hi Rodion,
its not a macro parameter, its part of the node property data.
I've confirmed that the data type is a DateTime by adding a parameter call
e.g Where("dateTime.value >= @0", date);
and getting 'value not a property of DateTime datatype'
also this working correctly
var d = dateTime.Month
<p>@d</p>
Hi. I think that simple replacing "date" with "Convert.ToDateTime(data)" should help.
same result.
whenever I access the dateTime property (which is a date picker with time, I get
Error loading Razor Script test.cshtml '.' or '(' expected
if I try and convert it (which I know it already is a DateTime data type) or use it directly it fails with this error. thats is only if I access it within the Where method
W
Ah, I understand. Your "date" is of the DateTime type and your "dateTime" is a datetime picker, right? So, actually the "dateTime" is a string that's actually a datetime formatted in a sortable "s" format (yyyy-MM-ddThh:mm). Your just need vice versa convert the "date" to a string with the sortable format too:
...Where("dateTime >= @0", date.ToString("s"));
Hello. This post helped me a lot and it worked perfectly. Thank you very much!
I created a docType called 'Evento' with a custom property called 'data' and it is formatted with date and time.
I need to get "today's" events even if your time is in the past. Could someone help me change the code below to make it work?
(forgive my bad English. I'm Brazilian)
is working on a reply...