• Hello Solomon, thanks for your reply. It's been a while but I use this code to compute a median for a list that varies every day.

    so basically date(T), median(list(T)).

    meaning : 01/02/2015 Median (list), 01/03/2015 Median (list) ....

    I think my work around was to exclude some dates and move on when it wasn't working. Now when I go and compute without the time series and look at a specific date , it works .

    For example when I have the time series with the specific condition

    "valuationdate > getdate() - 235" in the where statement which gives me data up to 06/09/2014 but I get the error message :

    Msg 6522, Level 16, State 2, Line 1

    A .NET Framework error occurred during execution of user-defined routine or aggregate "Agg_Median":

    System.InvalidOperationException: Failed to compare two elements in the array. ---> System.ArgumentException: At least one object must implement IComparable.

    System.ArgumentException:

    at System.Collections.Comparer.Compare(Object a, Object b)

    at System.Array.SorterObjectArray.SwapIfGreaterWithItems(Int32 a, Int32 b)

    System.InvalidOperationException:

    at System.Array.SorterObjectArray.SwapIfGreaterWithItems(Int32 a, Int32 b)

    at System.Array.SorterObjectArray.QuickSort(Int32 left, Int32 right)

    at System.Array.Sort(Array keys, Array items, Int32 index, Int32 length, IComparer comparer)

    at System.Collections.ArrayList.Sort(Int32 index, Int32 count, IComparer comparer)

    at System.Collections.ArrayList.Sort()

    at Agg_Median.Write(BinaryWriter ToBeSerialized)

    but when I exclude via inserting the following in the where statement

    and valuationdate not in ('06/06/2014','06/07/2014','06/08/2014') it still doesn't work if I increase to

    "valuationdate > getdate() - 236"

    And when I look at 06/08/2014 specifically, it returns no error message.

    Happy to share more data if needed.

    Thanks again.