Reply to Re: Simple SQL Query (To Neglect time from DateTime DataType)

Your name:

Reply:


Posted by Hugo Kornelis on 11/18/05 01:20

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)

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация