This is a migrated thread and some comments may be shown as answers.

Custom Attributes Format Time

2 Answers 84 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
.NET Coder
Top achievements
Rank 1
.NET Coder asked on 23 Jul 2008, 07:55 PM
I am trying to format a custom attribute to display the time only ex) 12:00 AM

Currently it displays as the entire date ex) 7/25/2008 12:00:00 AM

I am using the following Eval in the Appointment Template, but it is not displaying correctly.  This is a date/time field from a SqlDataSource.  Is this possible?

<%

#Eval("Attributes['Time']", "{0:t}")%>

Thanks for any assistance.

2 Answers, 1 is accepted

Sort by
0
Accepted
Simon
Telerik team
answered on 25 Jul 2008, 01:24 PM
Hi Wayne,

If you need to format a Date, you can use the DateTime.ToString("someFormat") method. Eval returns a string which cannot be formatted in the way you have tried.

For example, to formatted the time in the custom attribute, you can do the following:

<%# DateTime.Parse(Eval("Attributes['Time']").ToString()).ToString("t") %> 

Best wishes,
Simon
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
.NET Coder
Top achievements
Rank 1
answered on 29 Jul 2008, 03:33 PM
Thank you!  That is what I needed.
Tags
Scheduler
Asked by
.NET Coder
Top achievements
Rank 1
Answers by
Simon
Telerik team
.NET Coder
Top achievements
Rank 1
Share this question
or