【发布时间】:2013-03-26 01:11:34
【问题描述】:
我有两个 Edm.DateTime 类型的字段。我怎样才能获得 h:mm 格式的时间并将它们连接到 EntityDataSource 的 CommandText 中: “01/02/2013 3:15 AM 和 01/02/2013 4:15 AM”应该是“15:15-16:15” 我找到了 concat 的演员表,这是正确的解决方案吗:
CommandText="SELECT CAST([DoctorAppointment].[Start] AS System.String) + '--'+ CAST([DoctorAppointment].[End] AS System.String)
as Name FROM DatabaseEntities.DoctorAppointments as DoctorAppointment"
【问题讨论】:
-
我现在通过这个解决了问题,但我不确定:CAST(Hour(CAST([DoctorAppointment].[Start] AS System.DateTime))AS System.String)+':'+ CAST(Minute(CAST([DoctorAppointment].[Start] AS System.DateTime)) AS System.String) + '-' + CAST(Hour(CAST([DoctorAppointment].[End] AS System.DateTime)) AS System .String)+':'+ CAST(Minute(CAST([DoctorAppointment].[End] AS System.DateTime)) AS System.String)
标签: casting entitydatasource entity-sql