how to convert the dateformat 2007-12-02 00:26:00  into mm/dd/yyyy i.e 12/02/2007 in T_sql?

Posted on 2008-11-03
Last Modified: 2009-10-12
how to convert the dateformat 2007-12-02 00:26:00  into mm/dd/yyyy i.e 12/02/2007 in T_sql?
Question by:mshan
    LVL 2

    Accepted Solution

    Perhaps this will help.

    CONVERT (varchar(30), thedatestringhere, 101)

    Open in new window

    LVL 26

    Assisted Solution

    If you have a date as string(text) and you want to change the format you have to cast the string to datetime first:

          CONVERT (varchar(30), cast('2007-12-02 00:26:00' as datetime), 101) as date

    If is a column that is of datetime type then simply:

          CONVERT (varchar(30), datecolumn, 101) as date


    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    This is my first ever Article on EE or elsewhere; therefore, please bear with me if I have some discrepancies in my writing. I read many articles and questions related to "how to pass values to SSIS packages at run-time?"  Hence, this common ques…
    In this article—a derivative of my blog post (—I will explore a few different perspectives on which week today's date falls within using Microsoft SQL Server. First, to frame this stu…
    This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
    Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

    731 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

    15 Experts available now in Live!

    Get 1:1 Help Now