Home Forums SQL Server 2005 T-SQL (SS2K5) I am getting learn to post,am i correct now??????? What will be your reply for this??????? RE: I am getting learn to post,am i correct now??????? What will be your reply for this???????

  • andrewalex.r (4/10/2013)


    K, I need to change the format of the Date

    You can change the format for displaying the date using the convert function. For example:

    SELECT id,CONVERT(VARCHAR(10), DateValue, 101)AS 'MM/DD/4 digit year',CONVERT(VARCHAR(10), DateValue, 1) AS 'MM/DD 2 digit year'

    ,CONVERT(VARCHAR(10), DateValue, 4) AS 'German 2 digit year'

    ,CONVERT(VARCHAR(10), DateValue, 104) AS 'German 4 digit year' FROM #mytable

    Results:

    idMM/DD/4 digit yearMM/DD 2 digit yearGerman 2 digit yearGerman 4 digit year

    410/17/2007 10/17/07 17.10.0717.10.2007

    3710/17/2007 10/17/07 17.10.0717.10.2007

    For a rather complete outline of what you can do can be found at:

    http://www.sql-server-helper.com/tips/date-formats.aspx

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]