Jump to content
Xtreme .Net Talk

Displaying my dates without the time with # DataBinder.Eval(Container.DataItem, etc


Recommended Posts

Posted

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

Posted

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

Posted

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"/>

  • *Experts*
Posted

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() %>

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...