SQL 2005 DateFormatting / Output to custom value

Posted on 2009-12-28
Last Modified: 2012-05-08
I would like to take my field PatientProfile.Birthdate and make it 3 fields.

Example - DOB = 01/15/1960

I want this in my output

'DOBMonth' = 01
'DOBDay' = 15
'DOBYear' = 1960

Question by:JeffSturgeon2002
    LVL 81

    Accepted Solution

    Hello JeffSturgeon2002,

    Try :

    SELECT DATEPART(month,DOB) 'DOBMonth', DATEPART(day,DOB) 'DOBDay', DATEPART(year,DOB) 'DOBYear' FROM youTable

    Open in new window

    LVL 75

    Expert Comment

    by:Aneesh Retnakaran

    select DAY(dob), MONTH(dob ), YEAR(dob )
    from yourtable
    LVL 7

    Author Closing Comment

    LVL 81

    Expert Comment

    You're welcome! Thanks for the points and see you soon!

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Select dynamic rows as columns? 3 47
    Trigger for audit 26 42
    How to enforce inte 8 27
    SQL Select * from 6 25
    Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
    I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

    728 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

    18 Experts available now in Live!

    Get 1:1 Help Now