Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatting time in datalist

Status
Not open for further replies.

primagic

IS-IT--Management
Jul 24, 2008
476
0
0
GB
I have a field in an sql server table with a fieldtype of time.

I am trying to use the following code to format the time in a datalist

Code:
<%# Eval("AppointmentTime", "{0:hh:mm tt}") %>'

However I am getting the error 'Input string was not in a correct format.'

Help please

Thanks
 

The format function is expecting a date component along with the time. You can just convert your time column to a datetime in SQL which will introduce 1900-01-01 as the date along with the proper time. Since your eval will extract the time in the format you want, the date is ignored.

Code:
select convert(datetime, AppointmentTime) as AppointmentTime


Mark

"You guys pair up in groups of three, then line up in a circle."
- Bill Peterson, a Florida State football coach
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top