i have a datatable which contains two Datacolumns (date_start,date_sent) and i wanted to merge them into one single column (date_order) to then apply a sort like this:
DataRow[] dtSorted = dt.Select(null, "date_order DESC",DataViewRowState.CurrentRows);
Since whenever date_start is null, date_sent is not and vice versa, i tried the following expression to the datacolumn:
dt.Columns.Add("date_order", typeof(String), "IIF(date_start=NULL,date_sent,date_start)");
but its not working.Tried something like “ISNULL(date_start,date_sent),date_start” and “date_start + date_sent” but they didn’t work either.
Can someone please tell me what expression i should use? Thank you.
You should use the SQL COALESCE keyword, which returns the first non-null argument, e.g.:
That will return the first non-null out of date_order and date_sent