andycharger Posted April 21, 2004 Posted April 21, 2004 Im trying to dsplay my dates from my SQL SERVER dataase in my .net page Im using the following way of displaying it: <%# DataBinder.Eval(Container.DataItem, "phone_date") %> The problem is, it is displaying the date in a textbox as follows: 03/12/2003 00:00:00 I dont want the time bit appearing so is there a way to stop it showing? Thanks Andy Quote
sj1187534 Posted April 21, 2004 Posted April 21, 2004 Hi..I think you can do that like this: <%# Left(DataBinder.Eval(Container.DataItem, "phone_date"),10) %> Let me know if it works. SJ. Quote
Moderators Robby Posted April 21, 2004 Moderators Posted April 21, 2004 I'm sorry but that solution won't fly if the date is in any other format, you neet to apply a format style to the column or format the column in your select statement. Quote Visit...Bassic Software
sj1187534 Posted April 21, 2004 Posted April 21, 2004 Is it something like this: <%# Left(DataBinder.Eval(Container.DataItem, "phone_date").ToString(),10) %> I used the previous method myself but I got the data in the String format. So, I didn't have any problem. SJ Quote
tate Posted April 21, 2004 Posted April 21, 2004 Here is an example I quickly grabbed of formating a date field inside a datagrid column; <asp:BoundColumn HeaderText="Order Date" DataField="OrderDate" DataFormatString="{0:MM-dd-yy}" ItemStyle-HorizontalAlign="Center"/> Quote
*Experts* Bucky Posted April 21, 2004 *Experts* Posted April 21, 2004 Use DateTime.Parse() to turn your string into a DateTime variable, and then use the ToShortDateString() to return a string of just the date. <%# DateTime.Parse(DataBinder.Eval(Container.DataItem, "phone_date")).ToShortDateString() %> Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.