Custom KPI Error: The conversion of a datatype resulted in an out-of-range value

  • Updated

When the customer implements a custom KPI code for the A/B test with key-performance-indicators, it throws a database error when trying to start an A/B test with the customer KPI. 

The error message is:

The conversion of a datetime2 data type to a DateTime data type resulted in an out-of-range value.\r\n. The statement has been terminated.



The explanation and solution are stated here: the-conversion-of-a-datetime2-data-type-to-a-DateTime-data-type

One simple solution is to modify the constructor DemoKPI in the example KPI code as follows:

public DemoKpi()
this.CreatedDate = DateTime.UtcNow;
this.ModifiedDate = DateTime.UtcNow;
this._servicelocator = ServiceLocator.Current;