I hadn't yet needed to do this, but I'm kinda glad it works! Shame about
all those DATEADDs though... I've just run a test, and a
CAST(FLOOR(CAST (x as float)) as datetime)
is twice as quick... 2594ms [1310ms] vs 4579ms [2295ms]
(total-CPU-time [elapsed-time], based on 3773567 rows with a
non-clustered index on the time column, having pre-fetched the data
[logical reads], on a multi-core server).
OK, yes it is a blatant abuse of knowing the data-structure, but should
be fine for LINQ-to-SQL at least ;-p
I might drop a message on the LINQ General forum...
Marc
all those DATEADDs though... I've just run a test, and a
CAST(FLOOR(CAST (x as float)) as datetime)
is twice as quick... 2594ms [1310ms] vs 4579ms [2295ms]
(total-CPU-time [elapsed-time], based on 3773567 rows with a
non-clustered index on the time column, having pre-fetched the data
[logical reads], on a multi-core server).
OK, yes it is a blatant abuse of knowing the data-structure, but should
be fine for LINQ-to-SQL at least ;-p
I might drop a message on the LINQ General forum...
Marc