C# (ADO.Net): Defining DateDiff for a calculated column in a datatable
- by Nir
I have the column DateTimeExpired, and I would like to create another column called "Expired" which will show "Yes" or "No" according to the expiration date - "Yes" if the date has already passed.
I wrote this:
DataColumn colExpirationDate = new DataColumn("DateTimeExpired", typeof(DateTime));
DataColumn colExpired = new DataColumn("Expired", typeof(string), "IIF(DateDiff(DateTimeExpired, date())>= 0,'No','Yes')");
But I get an exception "The expression contains undefined function call DateDiff()."
(please note that I always want to get the row, no matter if it's expired or not)
How do I set the column's text to the correct form?
Thanks!