• Another option for ensuring the length of the individual dateparts is to left pad the value and retain the rightmost characters, thereby eliminating the case statement. This has come in handy in various situations.

    Thanks, Brett

    Declare @x int

    Set @x = 1

    Select Right('00' + Convert(varchar(2), @x), 2)

    Set @x = 12

    Select Right('00' + Convert(varchar(2), @x), 2)