C# (ADO.Net): 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:33 UTC
Read the original article
Hit count: 772
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!
© Stack Overflow or respective owner