Change date format

  • I am pulling data from SQL 2000 running on W2000 server and displaying in  an aspx page. My problem is I need to display it in this format dd-mmm-yyyy (or dd-mm-yyyy) but will only display in this format mm-dd-yyyy. I have changed the regional setting on the server to english-uk but this does not do it.

    Thanks for any help

    Danny

  • Using the following SQL statement after connecting to the database:

    SET DATEFORMAT dmy

  • You can also dynamically change the formatting of any date data simply by using the CONVERT function. If you use the help in SQL Query analyzer it will provide you with a grid that shows the relationship between formatting and format code. I think the one you would want, DD-MM-YYYY, would be 105. But if it's not the fit you want, you can look up the possibilities in the help.

    Sample Code

    select convert(char(10), getdate(), 105)

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

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