PC Review


Reply
Thread Tools Rate Thread

DataColumn Expressions and DateTime

 
 
William Ryan
Guest
Posts: n/a
 
      7th Aug 2003
SEt the value before you add it... and you'll need to use
a function to handle the addition.

Situation 1: Server Side...adjust your query ie DateAdd
(d, 50, oldDate)

Then you don't have to do anything client side...

Situation 2: Client side, more than a few ways but this
should give you the idea...
http://www.devhood.com/messages/message_view-2.aspx?
thread_id=71480

Remember one thing about Dates. On SQL Server and most
other DB's, there's no real Date Type.... It's DateTime,
and it's actually a long. If you look at the values a
LONG can hold, you'll see why January 1, 0001 is a valid
date but you can't query on it if it's a datetime field
in SQL Server. Int's and Long's don't play well together
in date math...

Anyway, this should do it for you, but just make sure you
use proper data arithmatic.

Good Luck,

Bill



Cordially,

W.G. Ryan
(E-Mail Removed)
www.knowdotnet.com


>-----Original Message-----
>I am adding an expression column to a datatable. The
>column is a DateTime and I am attempting to add x number
>of days to it. Below is the syntax where dt is the
>datatable
>
>dt.Columns.Add("NewDate",System.Type.GetType
>("System.DateTime"),"OldDate + 50");
>
>When I do this I get an error saying it can't add

DateTime
>and Int. Does anyone have any ideas as to how to
>accomplish this?
>.
>

 
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
Q: DataColumn Expressions G .Net Microsoft VB .NET 9 14th Dec 2006 04:48 PM
DataColumn Expressions =?Utf-8?B?TG9yZW5j?= Microsoft ADO .NET 5 15th Nov 2006 08:42 PM
Bug in Framework 1.1 SP1 for DataColumn Expressions in a DataGrid Ellen Microsoft Dot NET Framework Forms 0 18th Nov 2004 06:32 PM
Problem with expressions in DataColumn and ISupportInitialize Sam Dahan Microsoft ADO .NET 1 3rd Oct 2003 06:32 PM
datetime datacolumn Maurizio Microsoft ADO .NET 0 25th Aug 2003 09:44 PM


Features
 

Advertising
 

Newsgroups
 


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