473,394 Members | 1,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

DataTable - Date Difference

I am trying to set up an Expression column in a DataTable for display in a
DataGrid that subtract the column ("BirthDay") from todays date. I can't
seem to get it right...is this possible?
--
Dennis in Houston
Oct 10 '06 #1
4 2319
What do you have so far? What code are you using to populate the
datatable?

Thanks,

Seth Rowe
Dennis wrote:
I am trying to set up an Expression column in a DataTable for display in a
DataGrid that subtract the column ("BirthDay") from todays date. I can't
seem to get it right...is this possible?
--
Dennis in Houston
Oct 11 '06 #2
Dennis,

I don't know if it is possible, but the first thing you have to ask to
yourself is what difference do you want.

Days, Months, Years (I do not know how to get that in the expression).

Be aware what is nowhere told that you have to use the literal #MM-dd-yyyy#
expression for Dates in the expression. For you as American not such a
problem of course because that is in USA notation (for others who reads this
afterwards).

Cor

"Dennis" <De****@discussions.microsoft.comschreef in bericht
news:26**********************************@microsof t.com...
>I am trying to set up an Expression column in a DataTable for display in a
DataGrid that subtract the column ("BirthDay") from todays date. I can't
seem to get it right...is this possible?
--
Dennis in Houston

Oct 11 '06 #3
Below is what I've tried that I think is nearest to what might work. After
defining the datacolumn, I then add it to a datatable. Note that ""BirthDay"
is a column of type DateTime in the DataTable.

Dim col8 As DataColumn = New DataColumn("AgeToday",
System.Type.GetType("System.TimeSpan"),"#10-30-2006# - BirthDay")

The column get added to the datatable ok but when I fill in the "BirthDay"
column with some data, I get the error "cannot perform the operation on
System.DateTime and System.DateTime".

--
Dennis in Houston
"Cor Ligthert [MVP]" wrote:
Dennis,

I don't know if it is possible, but the first thing you have to ask to
yourself is what difference do you want.

Days, Months, Years (I do not know how to get that in the expression).

Be aware what is nowhere told that you have to use the literal #MM-dd-yyyy#
expression for Dates in the expression. For you as American not such a
problem of course because that is in USA notation (for others who reads this
afterwards).

Cor

"Dennis" <De****@discussions.microsoft.comschreef in bericht
news:26**********************************@microsof t.com...
I am trying to set up an Expression column in a DataTable for display in a
DataGrid that subtract the column ("BirthDay") from todays date. I can't
seem to get it right...is this possible?
--
Dennis in Houston


Oct 11 '06 #4
Dennis,

Now you write it, the timespan in the documentation is a documentation bug
that exist altready 3 years. It is reported by the way.

Cor

"Dennis" <De****@discussions.microsoft.comschreef in bericht
news:4E**********************************@microsof t.com...
Below is what I've tried that I think is nearest to what might work.
After
defining the datacolumn, I then add it to a datatable. Note that
""BirthDay"
is a column of type DateTime in the DataTable.

Dim col8 As DataColumn = New DataColumn("AgeToday",
System.Type.GetType("System.TimeSpan"),"#10-30-2006# - BirthDay")

The column get added to the datatable ok but when I fill in the "BirthDay"
column with some data, I get the error "cannot perform the operation on
System.DateTime and System.DateTime".

--
Dennis in Houston
"Cor Ligthert [MVP]" wrote:
>Dennis,

I don't know if it is possible, but the first thing you have to ask to
yourself is what difference do you want.

Days, Months, Years (I do not know how to get that in the expression).

Be aware what is nowhere told that you have to use the literal
#MM-dd-yyyy#
expression for Dates in the expression. For you as American not such a
problem of course because that is in USA notation (for others who reads
this
afterwards).

Cor

"Dennis" <De****@discussions.microsoft.comschreef in bericht
news:26**********************************@microso ft.com...
>I am trying to set up an Expression column in a DataTable for display in
a
DataGrid that subtract the column ("BirthDay") from todays date. I
can't
seem to get it right...is this possible?
--
Dennis in Houston



Oct 12 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Job Lot | last post by:
I have tow columns in my DataTable Date, Amount. What would be the best way to create multiple entries in my DataTable? I am given a start date, end date and an amount. I want to create multiple...
6
by: Willie wjb | last post by:
Hi, i have a client program that sends a filter expression to the server PC. On that server PC this filter is put over a datatable and the result is send back. the server can be located on a...
6
by: Millo | last post by:
Hi I'm trying to call the method Contains in a loop: out of the loop I set the primary key of the dataTable. The method returns true one time at a certani value, but then, when the loop steps...
5
by: Thomas Scheiderich | last post by:
I am having a problem with a Datatable access. This statement apparently works fine: response.write(GetRows.Rows(ktr)(1)) and this statement does not: if e.day.date = GetRows(ktr)(1) then
2
by: ven | last post by:
Hello i have a dynamic datatable in my page. I wanna to write data to textboxes and after click on button "ADD data" i want to refresh datagrid on page... Here is my code : ' Insert page code...
6
by: ronchese | last post by:
Hi. I'm trying to make a criteria string to use in Select() method of a datatable, searching for a date, but it is apparently not working! In one of my tests, I have a datatable with 1 row and...
3
by: Jeff | last post by:
hey ..NET 2.0 I have a datatable which consist of 3 columns (int, date, value). This DataTable have 3 rows, the values of the "date" ("date" column is of datetime datatype) column is:...
5
by: jehugaleahsa | last post by:
Hello: What is the point of using a DataTable in ASP .NET? We are unsure how you can use them without 1) rebuilding them every postback, or 2) taking up precious memory. We are not sure how to...
2
by: Taftheman | last post by:
Hi, I am trying to do some data checking before commiting the data back to the database. I have a datagrid in this data grid i have textboxes. The user can edit what they like. The first row in the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.