Link to home
Start Free TrialLog in
Avatar of Erwin Pombett
Erwin PombettFlag for Switzerland

asked on

i cannot display only date : "01/01/2008", this date is always accompanied with hours: "01/01/2008 00:00:00", how to correct?

hello,

i have a datatable with a columns which is set as a datetime,
i've been trying to display only the date without hours, minutes and seconds,

i've try several Datetime members in order to change the display without success,
how can i get rid of the hours?
datatable:      
myDt.Columns.Add("a_date", typeof(DateTime));
html :
<td class="td_125"><%# DataBinder.Eval(Container.DataItem, "a_date") %></td>
filling the datatable:
//_aRow["a_date"]    = (container.Status.NextDateFullFill().ToShortTimeString()).Split(' ')[0]; 
_aRow["a_date"]    = ((DateTime)container.Status.NextDateFullFill()).ToShortDateString(); //.Substring(0, 10); 
                      ....
how to get rid of those chars, 
i need to filter through this column, i think i need it typed as a datatable, 
thank you for your help,

Open in new window

Avatar of ccns
ccns
Flag of New Zealand image

Hi there have a look at this link may anser your Q:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2674122&SiteID=1
ASKER CERTIFIED SOLUTION
Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Erwin Pombett

ASKER

it's exactly what i'm doing,
i'm casting to dateTime, then using the toshortdatestring(),

in my case this is not working, the display put the hours to 00:00:00 is all i could change with the solution
you linked me to.
......
and that's the same i'm stack with
ToShortDateString() cannot show 00:00:00
Maybe you have a compile refresh problem.
indeed ToShortDateString() wouldn't display the "00:00:00"
but only if the columnType is string,  i wanted it on dateTime for sorting,  and with dateTime  for the column i always have the date with the time.

my last choice is to show only date created by numbers in order to sort the datatable correctly on date.


it is not easy to help you because you are not being specific.
Are you using a datagrid? a textbox binded to a datetime field?
In every case, you can have set some Format property to show just date
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
if its data in a datatable.. you must first decare the data type as System.DateTime
carlsiy,  is what i did, in my datatable the column is declared as a datetime.

ragi0017,  i did not know i could do this,  but i think that the value to convert should be a string, am i right?

jaime olivares, i'm imrpoving my questioning skills, sorry for the lack of informations,  


all info:
my datatable column is declared as datetime,
i'm filling my columns with a dateTime value,
....
it should work - may be a little tweak but try it out and if its still an issue let me know i will be happy to help out
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial