views:

383

answers:

2

Hi everyone!!

I have a lambda expression that has this:

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?

I've tried to use some kinda 'convert(startime, getdate(),8) but it didn't work.

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).

Thanks!!!

A: 

Have you tried:

CAST(starttime as time)

Have a look at this for more detail time (Transact-SQL)

Lazarus
+1  A: 

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
Mitch Wheat
round? why not floor?
dotjoe