DATENAME([Year],
dbo.reservation.begintime) + N’年’ + CAST(DATEPART([Month],
dbo.reservation.begintime) AS varchar) + N’月’ + DATENAME([Day],
dbo.reservation.begintime) + N’日’ + DATENAME([Hour], dbo.reservation.begintime)
+ N’点’ + DATENAME([Minute], dbo.reservation.begintime) + N’分’ AS btime
处理一个时间段不在另一个时间段的方法。
select * from dbo.reservation where getdate() not between begintime and endtime;
错误 108 “System.Nullable<System.TimeSpan>”不包含“Hours”的定义,并且找不到可接受类型为“System.Nullable<System.TimeSpan>”的第一个参数的扩展方法“Hours”(是否缺少 using 指令或程序集引用?)
解决: TimeSpan parseTime =(System.TimeSpan)(endtime - begintime);
RadioButtonList1.Items.FindByValue(parseTime.Hours.ToString()).Selected = true;
select * FROM 表 where ((’2010-06-07 03:35:00’ between begintime and endtime) or (’2010-06-07 9:35:00’ between begintime and endtime) or (begintime between ’2010-06-07 03:35:00’ and ’2010-06-07 9:35:00’) or (endtime between ’2010-06-07 03:35:00’ and ’2010-06-07 9:35:00’))