Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
700
Get start and end time for a RelativeDateOperand
posted

Hi,

we are using the RelativeDateOperand-Condtions like "LastMonth" for some fields in our grid. Now we want to use the start and end time of these timespans for a where clause.

I was able to get the start- and end time in the RecordFilterChanged Eventhandler by using Reflection on the ComparisonCondition object with:

var fieldEndTime = condValue.GetType().GetField("cachedEnd", System.Reflection.BindingFlags.Public |

System.Reflection.BindingFlags
.NonPublic |
System.Reflection.BindingFlags.Instance);

It doesn't look very clean but it works. Now we need start and end time before initializing the grid. Is there a chance to get the two dates for a RelativeDate? 

kind regards

Hase   

 

    

  • 54937
    Offline posted

    Well the dates are cached when the operand is used to evaluate a match so you could get the operand you want from the static properties on the SpecialFilterOperands class and call the IsMatch method. Note the operands returned there are wrappers so you would need to get the "_cachedOperand" from it to get the relative date operand.

    var operand = SpecialFilterOperands.LastMonth;

    // note if you're not using currentculture then you'll need a custom
    // derived context where the Culture of the CurrentValue has the
    // culture you are using
    operand.IsMatch(ComparisonOperator.Equals, DateTime.Today, null);