Home All Groups Group Topic Archive Search About

DataTable - Date Difference

Author
10 Oct 2006 9:58 PM
Dennis
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

Author
11 Oct 2006 12:32 AM
rowe_newsgroups
What do you have so far? What code are you using to populate the
datatable?

Thanks,

Seth Rowe


Dennis wrote:
Show quoteHide quote
> 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
Author
11 Oct 2006 5:15 AM
Cor Ligthert [MVP]
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

Show quoteHide quote
"Dennis" <Den***@discussions.microsoft.com> schreef in bericht
news:26820E26-6456-4594-8099-1D1C13307A99@microsoft.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
Author
11 Oct 2006 11:53 PM
Dennis
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


Show quoteHide quote
"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" <Den***@discussions.microsoft.com> schreef in bericht
> news:26820E26-6456-4594-8099-1D1C13307A99@microsoft.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
>
>
>
Author
12 Oct 2006 5:02 AM
Cor Ligthert [MVP]
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

Show quoteHide quote
"Dennis" <Den***@discussions.microsoft.com> schreef in bericht
news:4E27BEF8-B033-4098-A719-2C9669C770AF@microsoft.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" <Den***@discussions.microsoft.com> schreef in bericht
>> news:26820E26-6456-4594-8099-1D1C13307A99@microsoft.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
>>
>>
>>