J
Jesper Pedersen
Hi ! please help - I have tabel with a Birthday column in a access database
and need to show the age in a datagrid.
-------------------------------------------------------------------
found this little code:
-------------------------------------------------------------------
<%
DateTime birthDate = new DateTime(1986, 12, 25); //A wonderful day for me!
TimeSpan age = DateTime.Now - birthDate;
//age contains my age (the time from my birthday to the current time)
Response.Write("I am " + (age.TotalDays/365.25) + " days old!");
%>
--------------------------------------------------------------------
It works fine, but how should i do in my example here:
--------------------------------------------------------------------
<%
OleDbConnection Conn;
OleDbCommand Cmd;
Conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=\\database.mdb");
Cmd = new OleDbCommand("SELECT Birthday FROM tabel ,Conn);
Conn.Open();
DataGrid1.DataSource = Cmd.ExecuteReader();
DataGrid1.DataBind();
Conn.Close();
%>
<asp
ataGrid id="DataGrid1" runat="server">
<asp:TemplateColumn HeaderText="Age">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "Birthday") %>
</ItemTemplate>
</asp:TemplateColumn>
</asp
ataGrid>
Instead of the Birthday i want the Age to be printet
and need to show the age in a datagrid.
-------------------------------------------------------------------
found this little code:
-------------------------------------------------------------------
<%
DateTime birthDate = new DateTime(1986, 12, 25); //A wonderful day for me!
TimeSpan age = DateTime.Now - birthDate;
//age contains my age (the time from my birthday to the current time)
Response.Write("I am " + (age.TotalDays/365.25) + " days old!");
%>
--------------------------------------------------------------------
It works fine, but how should i do in my example here:
--------------------------------------------------------------------
<%
OleDbConnection Conn;
OleDbCommand Cmd;
Conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=\\database.mdb");
Cmd = new OleDbCommand("SELECT Birthday FROM tabel ,Conn);
Conn.Open();
DataGrid1.DataSource = Cmd.ExecuteReader();
DataGrid1.DataBind();
Conn.Close();
%>
<asp
<asp:TemplateColumn HeaderText="Age">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "Birthday") %>
</ItemTemplate>
</asp:TemplateColumn>
</asp
Instead of the Birthday i want the Age to be printet