How to Change the default date format in sql server 2005...

  • Hi..

    I agree with u..

    But whats my friend's requirement is to change the settings which attained by sql server 2005..

    by default it is coming like

    SET DATEFORMAT mdy;

    select getdate()

    Result:

    2008-07-28 10:26:25.920

    Can I able to change it in to Date/month/Year format

    Ramkumar . K
    Senior Developer
    ######################
    No Surrender... No Give Up....
    ######################

  • SET DATEFORMAT setting is used only in the interpretation of character strings as they are converted to date values. It does not affect the display of date values.

    MSDN http://msdn.microsoft.com/en-us/library/ms189491.aspx

    To get your erequired format Try...

    Select Convert(varchar(10), getdate(),103)

    Atif Sheikh

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Sometimes, winning is not an issue but trying.
    You can check my BLOG
    [font="Arial Black"]here[/font][/url][/right]

  • ramkumar (7/27/2008)


    Hi..

    I agree with u..

    But whats my friend's requirement is to change the settings which attained by sql server 2005..

    by default it is coming like

    SET DATEFORMAT mdy;

    select getdate()

    Result:

    2008-07-28 10:26:25.920

    Can I able to change it in to Date/month/Year format

    You agree with who?

    Standard advice: The format in SQL Server shouldn't matter. You should not do formatting there, but in the front-end.

    You can't change a setting to get SQL Server to display the result of getdate() differently. The only thing you can do - if you must do it - is modify the T-SQL to convert it to a string and format it as required. e.g.

    select convert(varchar(30), getdate(), 103)

    See http://msdn.microsoft.com/en-us/library/ms187928.aspx for more convert options.

    Ryan Randall

    Solutions are easy. Understanding the problem, now, that's the hard part.

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

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