Advanced math

  • Thread starter Thread starter Joe
  • Start date Start date
J

Joe

Does anyone know of any advanced math library's or a way to use math with a
DataTime DataColumn?
 
I am brainstorming here, but I think you can get the ticks via a TimeSpan
object from your DateTime struct to a struct from DateTime.Min

TimeSpan ts = MyDateTime - DateTime.MinValue;

You can then do a comparison to two dates in pure math, for example:

TimeSpan ts = MyDateTime - DateTime.MinValue;
TimeSpan ts2 = SecondDateTime - DateTime.MinValue;

To use math, you just need a common zero value to start with, which
DateTime.MinValue supplies.

What do you want to do with the date/time you are working with? Knowing this
might help me lead you to other ideas.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://feeds.feedburner.com/GregoryBeamer#

or just read it:
http://feeds.feedburner.com/GregoryBeamer

********************************************
| Think outside the box! |
********************************************
 
I probably should have explained it more.

We want to have a DataColumn.Expression = MyDateField + 365.
MyDateField is another field in the DataTable and we want to add 365 days or
some other value to it.
 
Take a look at something like this:

Dim StartDate As DateTime = DateTime.Today
Dim x As Integer = 365
StartDate.AddDays(x)

(written in notepad ) but that should do the trick.
 
One way to do that is write a custom SQL statement to add the year

You can also use the row binding event to add another column. Just cast the
value into a DateTime (it should already be there with automagic stuff) and
use

MyDateTime.AddDays(365)

as the value for the column.

Hope this helps!

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://feeds.feedburner.com/GregoryBeamer#

or just read it:
http://feeds.feedburner.com/GregoryBeamer

********************************************
| Think outside the box! |
********************************************
 
Back
Top