471,354 Members | 1,070 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,354 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 2139
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Job Lot | last post: by
6 posts views Thread by Millo | last post: by
5 posts views Thread by Thomas Scheiderich | last post: by
2 posts views Thread by ven | last post: by
6 posts views Thread by ronchese | last post: by
3 posts views Thread by Jeff | last post: by
5 posts views Thread by jehugaleahsa | last post: by

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.