Converting a Date format?

Posted on 2008-11-05
Last Modified: 2010-03-20
I am trying to update the format of dates stored within a table they are currently stored as:


and I would like to convert it to:


I am storing these as a nvarchar(50)

Any ideas would be great.
Question by:directxBOB
    LVL 6

    Accepted Solution

    You should store date as datetime type not nvarchar.

    anyways... for SQL Server 2005 it looks like this..

    SELECT Substring('2008-10-16', 9, 2) + '/' + Substring('2008-10-16', 6, 2) + '/' + Substring('2008-10-16', 1, 4)

    you would replace '2008-10-16' with the column name:

    UPDATE [TABLE] SET DateColumn = Substring(DateColumn, 9, 2) + '/' + Substring(DateColumn, 6, 2) + '/' + Substring(DateColumn, 1, 4)
    If you give more details about your table I can provide a better query.

    Open in new window

    LVL 2

    Assisted Solution

    try this
    declare @date datetime 
    set @date = '2008-10-16'
    select convert(varchar(10),@date,103)

    Open in new window


    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
    This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now