This is a migrated thread and some comments may be shown as answers.

Condtional Formatting Based On Time Difference

2 Answers 84 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Graham
Top achievements
Rank 2
Iron
Iron
Graham asked on 04 May 2017, 02:48 PM

I want to do conditional formatting on a particular column called "HubArrival" which is DateTime format. I want it to have a pink background if the difference between HubArrival and BookedArrival is greater than 45 minutes, and I have set up conditional formatting to do this. Here is the code from the resulting designer file:

 

formattingRule2.Filters.Add(new Telerik.Reporting.Filter("AddMinutes(Fields.BookedArrival, 45)", Telerik.Reporting.FilterOperator.LessThan, "Fields.HubArrival"));

 

On running the report, an error occurs stating that DateTime cannot be compared with text - but both fields are of type DateTime.

2 Answers, 1 is accepted

Sort by
0
Graham
Top achievements
Rank 2
Iron
Iron
answered on 04 May 2017, 03:23 PM

Got there in the end. Needed to select <expression> on both sides of the inequality and also handle nulls. I ended up with...

 

formattingRule2.Filters.Add(new Telerik.Reporting.Filter("= AddMinutes(IsNull(Fields.BookedArrival, AddDays(Today(), 5)), 45)", Telerik.Reporting.FilterOperator.LessThan, "= IsNull( Fields.HubArrival, AddDays(Today(), -5))"));
0
Accepted
Graham
Top achievements
Rank 2
Iron
Iron
answered on 04 May 2017, 03:24 PM

Got there in the end - had the select <expression> on ether side of the inequality, and handle nulls. I ended up with...

 

formattingRule2.Filters.Add(new Telerik.Reporting.Filter("= AddMinutes(IsNull(Fields.BookedArrival, AddDays(Today(), 5)), 45)", Telerik.Reporting.FilterOperator.LessThan, "= IsNull( Fields.HubArrival, AddDays(Today(), -5))"));

Tags
General Discussions
Asked by
Graham
Top achievements
Rank 2
Iron
Iron
Answers by
Graham
Top achievements
Rank 2
Iron
Iron
Share this question
or