• Avi1 - Friday, October 13, 2017 12:40 PM

    I tested the scripts in one of dev box in SQL2016. the results are below. Each scripts ran 100 times (at 2 different times)
    Included the method suggested by Scott Pletcher 

    CONVERT(CHAR(2), SomeDate, 1)

    Run#1
    Method        AvgTime(ms)
    PRECAST Method        553.07    
    DATENAME Method        518.48    
    MATH OVERRUN Method    526.75    
    ScottPletcher Method    483.83    

    Ru#2
    PRECAST Method        565.5    
    DATENAME Method        515.25    
    MATH OVERRUN Method    526.97    
    ScottPletcher Method    501.11

    Sure, it can be faster. Are you sure that it's correct?

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2