Skip to main content

MatBailie

Member since Dec 11, 2008

Recent Blog Comments By MatBailie

  • Getting Only the Date Part of a Date/Time Stamp in SQL Server

    Posted on Oct 7, 2010 at 9:21 AM

    @Purushothaman, DECLARE @mydatetime DATETIME SET @mydatetime = '09:10' SET @mydatetime = DATEADD(HOUR, 2, @mydatetime) SELECT @mydatetime... read more »

  • Getting Only the Date Part of a Date/Time Stamp in SQL Server

    Posted on Nov 9, 2009 at 5:01 PM

    Anyone that converts any data type (DateTime or otherwise) to a string for Manipulation is likely never to work on any team with me. Without very specific case by case reasoning, it should only be done if the String is the desired end result (such as for an email). Definately not if you're going t... read more »

  • Getting Only the Date Part of a Date/Time Stamp in SQL Server

    Posted on Aug 21, 2009 at 12:34 PM

    I wouldn't even tend to use SQL for that either. I'd use the client. Pass the data to the client as a DateTime and then let the client format it however it wants. A principle I try to adhere to is that the SQL Server code should not be concerned by display issues. By moving that to a different l... read more »

  • Getting Only the Date Part of a Date/Time Stamp in SQL Server

    Posted on Aug 21, 2009 at 8:19 AM

    I agree with KISS. But part of that, imho, is to avoid manipulations on undefined behaviour. Although a binary manipulation of a float representation of DateTime does work, it's not a guaranteed behaviour. Conversley using DATEADD and DATEDIFF are highly explicit and should be easy to understand.... read more »

  • Getting Only the Date Part of a Date/Time Stamp in SQL Server

    Posted on Aug 20, 2009 at 9:08 AM

    There are many tests that I have seen run to compare the two options. Unfortunately I've also seen very few that I consider reliable. Some use Stored Procedures, some use inline queries. Some base it on time, some on reads, some on relative query load when looking at execution plans. Some are fl... read more »

  • Getting Only the Date Part of a Date/Time Stamp in SQL Server

    Posted on Aug 20, 2009 at 8:41 AM

    Oh, and it's a good inteview question too. Anyone, and I really mean this, who proposes string manipulation to solve mathmatical issues should never work for your company. People don't understand the overhead of string manipulation don't understand enough to Ever be able to predict the consequence... read more »

  • Getting Only the Date Part of a Date/Time Stamp in SQL Server

    Posted on Aug 20, 2009 at 8:36 AM

    The DATEDIFF is fast Because it doesn't have to do conversions (implicit or explicit) on the target data field. It is also implementation independant. And it's SARGable. It doesn't bust the optimiser's ability to utilize indexes. From both performance and engineering perspectives it's the way to... read more »

  • Getting Only the Date Part of a Date/Time Stamp in SQL Server

    Posted on May 15, 2008 at 8:55 AM

    I've read a lot of comments and the main pieces of advice I have are: - Avoid strings, they're slow - Some operations take longer than others - 2 quick operations can be faster than 1 slow operation - Although "an integer can be used as a date" the database engine still has to do an 'implicit' CAST ... read more »

I believe in love. I believe in compassion. I believe in human rights. I believe that we can afford to give more of these gifts to the world around us because it costs us nothing to be decent and kind and understanding. And, I want you to know that when you land on this site, you are accepted for who you are, no matter how you identify, what truths you live, or whatever kind of goofy shit makes you feel alive! Rock on with your bad self!
Ben Nadel