Format Date with leading zeroes (T-SQL and VBScript)

  • Would someone please show me how to take a date and format it with leading zeroes. For example, 4/9/2005 and format it as 04/09/2005 (mm/dd/ccyy). I would like to know how to do this using T-SQL and ActiveXScript.

    Thanks in advance, Kevin

  • Kevin, for the T-SQL portion, there are lots of ways to do it.  One way is:

    select convert(varchar(10),cast('4/9/2005' as datetime),101)

    To learn more, here's a good article from MVP Frank Kalis:

    http://www.sql-server-performance.com/fk_datetime.asp

    HTH, Linda

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply