Defining DateDiff for a calculated column in a datatable

Posted by Nir on Stack Overflow See other posts from Stack Overflow or by Nir
Published on 2010-04-15T08:29:06Z Indexed on 2010/04/15 8:43 UTC
Read the original article Hit count: 617

Filed under:
|

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?

© Stack Overflow or respective owner

Related posts about c#

Related posts about ADO.NET