In SQL Server how do I isolate just the date portion of a date time field.

Posted on 2012-08-23
Last Modified: 2012-08-23
I have a field enrollment_date that is on a table in SQL Server.  How do I isolate just the date portion?

I don't want just day, month or year but 08/31/2012.
Question by:morinia
    1 Comment
    LVL 142

    Accepted Solution

    you may want to read up this article:

    in your case, you have 2 options, based on the fact if you need the date for display or for calculations.
    if it's for display:
    CONVERT(VARCHAR(10), enrollment_date, 101)

    if it's for calculation:
    CONVERT(datetime, CONVERT(varchar(10), enrollment_date, 101), 101)

    Featured Post

    PRTG Network Monitor: Intuitive Network Monitoring

    Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

    Join & Write a Comment

    Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
    Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
    Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
    Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

    746 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

    16 Experts available now in Live!

    Get 1:1 Help Now