Date issue

  • i have a column called DOB(datatype :datetime) in my table A which as values like as follows

    DOB

    1925-12-19 00:00:00.000

    1935-04-10 00:00:00.000

    1929-08-19 00:00:00.000

    I WANT IT TO UPDATE IT WITH VALUES AS FOLLOWS for that column in my table

    12/19/1925

    04/10/1935

    08/19/1929

  • Best (10/14/2008)


    i have a column called DOB(datatype :datetime) in my table A which as values like as follows

    DOB

    1925-12-19 00:00:00.000

    1935-04-10 00:00:00.000

    1929-08-19 00:00:00.000

    I WANT IT TO UPDATE IT WITH VALUES AS FOLLOWS for that column in my table

    12/19/1925

    04/10/1935

    08/19/1929

    No, you really don't. Dates have a huge number of uses even for things as simple as a DOB. But you won't be able to do any of them if you format a date like that because you'll need to store it as a VARCHAR. Use CONVERT to display it any way you want, but don't store it as anything other than a datetime. Lookup CONVERT in Books Online to see how the following works...

    SELECT CONVERT(CHAR(10),DOB,101)

    FROM yourtable

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)
    Intro to Tally Tables and Functions

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

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