Display only date in a ASP.NET template field

I have one ASP.NET web form using a Detail View, DV1 which is bound to an object data source, ODS.

i have a template field in DV1, and it's bound to a field in the ODS as :

                    <asp:Label ID="LB1" runat="server" Text='<%# Bind("tDate") %>'> </asp:Label>
When loaded the DV1 displays the date and the time in the field, how can i only display the date?
Who is Participating?

Improve company productivity with a Business Account.Sign Up

Seven priceConnect With a Mentor Full StackCommented:
Is the data in the table.?  If so how are you selecting the date?

and you could select the date like.

         <asp:Label ID="LB12" runat="server" visible="false" Text='<%# Bind("id") %>'> </asp:Label>
                    <asp:Label ID="LB1" runat="server" Text='<%# Bind("tDate") %>'> </asp:Label>

        <%#DataBinder.Eval(Container.DataItem, "tDate", "{0:MM-dd}")%>

and then choose a format.

Nyana22Author Commented:
in the database table the filed in datetime in MySQL.

but in the query i am using select date(field)....
in the database it's only showing the date from the datetime,
but the weird stuff is in the web form it's showing everything, even  if i am using the function date...
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.