PC Review


Reply
Thread Tools Rate Thread

DataColumn.Expression complex calculations

 
 
=?Utf-8?B?QW1pciBTaGl0cml0?=
Guest
Posts: n/a
 
      18th Jun 2005
Hi.
Does anybody know how to perform complex calculations using the
DataColumn.Expression property?
Specifically, I'm trying to calculate the difference between a DateTime
column and the current date:
DateTime.Now.Subtract(certainDate).TotalDays

Is there a way to integrate custom functions in this property?
 
Reply With Quote
 
 
 
 
Miha Markic [MVP C#]
Guest
Posts: n/a
 
      19th Jun 2005
Hi Amir,

I think that it is best to manually perform such calculations in this case.
Refresh them in ColumnChanged event and do an DataRowAcceptChanges if he row
wasn't modified before.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/
SLODUG - Slovene Developer Users Group www.codezone-si.info

"Amir Shitrit" <(E-Mail Removed)> wrote in message
news:5D9C661C-1C29-465C-A4E1-(E-Mail Removed)...
> Hi.
> Does anybody know how to perform complex calculations using the
> DataColumn.Expression property?
> Specifically, I'm trying to calculate the difference between a DateTime
> column and the current date:
> DateTime.Now.Subtract(certainDate).TotalDays
>
> Is there a way to integrate custom functions in this property?



 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      19th Jun 2005
Amir,

In my opinion is the expression not to for doing *complex* calculations.

http://msdn.microsoft.com/library/de...ssionTopic.asp

On this page is only with this sample given how to use dates
"Birthdate < #1/31/82#"

Be aware that because every thing in dotNet is nicely globalized done, you
have to investigage how it has to be used with computers outside the USA,
because this is a typical USA notation and I don't know if it is for
computers (beside English speaking Canada) in the rest of the world
accoording those culture/language notations..

I hope this helps,

Cor


 
Reply With Quote
 
Val Mazur \(MVP\)
Guest
Posts: n/a
 
      19th Jun 2005
Hi,

What you could do is to catch an event of the DataTable when DataRow inside
of it has been changed and calculate new date inside of this event. Then
assign value to the column. At least it will work in all the cases when row
was modified
--
Val Mazur
Microsoft MVP

http://xport.mvps.org



"Amir Shitrit" <(E-Mail Removed)> wrote in message
news:5D9C661C-1C29-465C-A4E1-(E-Mail Removed)...
> Hi.
> Does anybody know how to perform complex calculations using the
> DataColumn.Expression property?
> Specifically, I'm trying to calculate the difference between a DateTime
> column and the current date:
> DateTime.Now.Subtract(certainDate).TotalDays
>
> Is there a way to integrate custom functions in this property?



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
datacolumn.expression Victor Microsoft Dot NET Compact Framework 1 14th Mar 2005 11:18 PM
Calculations with DateTime fields using DataColumn.Expression stri =?Utf-8?B?TWF0dA==?= Microsoft Dot NET Framework Forms 2 2nd Jan 2005 06:19 AM
Complex Aggregate Expression in DataColumn =?Utf-8?B?UGF1bDIwMDQ=?= Microsoft ADO .NET 1 15th Dec 2004 11:49 AM
DataColumn Expression Joel Rumerman Microsoft Dot NET Framework Forms 10 11th Aug 2004 09:03 AM
DataColumn.Expression Christopher Dedels Microsoft ADO .NET 5 10th May 2004 12:14 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:10 PM.