On 17 Nov 2005 14:52:41 -0800, ZeldorBlat wrote:
If you wanto remove the time portion and keep the value as datetime
(instead of char) you can use this:
CAST(FLOOR(CAST(someDate AS float)) AS datetime)
I always thought that was a nifty idiom -- but I'm not sure of the
performance implications (if any).
Hi ZeldorBlat,
This works, but it relies on the (undocumented, as far as I know)
conversion rules for datetime to float and float to datetime. Relying on
undocumented behaviour is allways dangerous.
Here's a safer way to trim the time from a date while still getting a
datetime result:
DATEADD(day, DATEDIFF(day, '20000101', someDate), '20000101')
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)