473,373 Members | 1,553 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,373 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 2318
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.