I have a lambda expression that has this:
我有一个lambda表达式有这个:
Convert.ToDateTime(a.startTime).TimeOfDay >= Convert.ToDateTime(startTime).TimeOfDay
But, I have to create a procedure in SQL Server and how should be the statement above to SQL statement?
但是,我必须在SQL Server中创建一个过程,如何将上述语句用于SQL语句?
I've tried to use some kinda 'convert(startime, getdate(),8) but it didn't work.
我试过使用某种'转换(startime,getdate(),8),但它没有用。
And I forgot to say that 'startTime' is a DateTime field and I'm trying to compare only the time part (forget about the date part).
我忘了说'startTime'是一个DateTime字段,我试图只比较时间部分(忘记日期部分)。
Thanks!!!
2 个解决方案
#1
From here:
CREATE FUNCTION dbo.TIMEVALUE
(
@Datetime datetime
)
/*******************************************************************************
* AUTHOR: Luciano Evaristo Guerche *
*******************************************************************************/
RETURNS datetime
AS
BEGIN
RETURN (@Datetime - CAST(ROUND(CAST(@Datetime AS float), 0, 1) AS datetime))
END
GO
#2
Have you tried:
你有没有尝试过:
CAST(starttime as time)
Have a look at this for more detail time (Transact-SQL)
看看这个更详细的时间(Transact-SQL)
#1
From here:
CREATE FUNCTION dbo.TIMEVALUE
(
@Datetime datetime
)
/*******************************************************************************
* AUTHOR: Luciano Evaristo Guerche *
*******************************************************************************/
RETURNS datetime
AS
BEGIN
RETURN (@Datetime - CAST(ROUND(CAST(@Datetime AS float), 0, 1) AS datetime))
END
GO
#2
Have you tried:
你有没有尝试过:
CAST(starttime as time)
Have a look at this for more detail time (Transact-SQL)
看看这个更详细的时间(Transact-SQL)