View Single Post

   
  #5 (permalink)  
Old 04-08-2008, 06:16 PM
Bernd Giegerich
 
Posts: n/a
Default Re: How to retrieve the date part of a DATETIME column via (T-)SQL?

Kristian Damm Jensen wrote:

> declare @d datetime
> set @d = getdate()
> convert(varchar, @d, 112)
>
> ... return the current date as '20060131'.
>
> That may not be pretty (a concern if this is to be displayed to an
> end-user), but it *is* sortable.


yep, that's more or less what I'm doing here by now.

I thought, that there may be a better solution around, as e.g.
aggregating on the day part of DATETIMEs is surely very common, but it
looks as I didn't miss a chapter in the "date functions" chapter of my
SQL book... :-)

Thanks,
Bernd
Reply With Quote