[Webinar] Learn how to a build a cloud-first strategyRegister Now


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

Posted on 2012-08-23
Medium Priority
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 143

Accepted Solution

Guy Hengel [angelIII / a3] earned 2000 total points
ID: 38325468
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how the fundamental information of how to create a table.
Suggested Courses

865 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