【发布时间】:2014-09-12 01:25:44
【问题描述】:
我正在尝试将datetime2 与time(7) 进行比较
我需要帮助转换datatime2。
这是我尝试过的:
DECLARE @PracticeStartTime time(7)
DECLARE @PracticeEndTime time(7)
SET @PracticeStartTime = (
SELECT PBH.StartTime
FROM PracticePractitioner AS PP WITH (NOLOCK)
LEFT JOIN PracticeBusinessHours AS PBH WITH (NOLOCK)
ON PBH.PracticeId = PP.PracticeId
WHERE PP.PractitionerId = @PractitionerId
)
SET @PracticeEndTime = (
SELECT PBH.EndTime
FROM PracticePractitioner AS PP WITH (NOLOCK)
LEFT JOIN PracticeBusinessHours AS PBH WITH (NOLOCK)
ON PBH.PracticeId = PP.PracticeId
WHERE PP.PractitionerId = @PractitionerId
)
IF (
(
CONVERT(@ScheduledStart AS TIME) BETWEEN @PracticeStartTime
AND @PracticeEndTime
)
AND (
CONVERT(@ScheduledEnd AS TIME) BETWEEN @PracticeStartTime
AND @PracticeEndTime
)
)
BEGIN
PRINT 'Time within practice hours';
END
ELSE
BEGIN
RETURN - 1
END
【问题讨论】:
-
您是否收到错误消息?这是 MSSQL 吗?
-
@JChao sql 错误:消息 102,级别 15,状态 1,过程 AppointmentByModalCreate,第 57 行“@ScheduledStart”附近的语法不正确。
标签: sql sql-server datetime time converter