Solved

How can I convert this to date only

Posted on 2009-07-14
6
207 Views
Last Modified: 2012-05-07
SELECT * FROM (SELECT  Distinct c.CustomerID,  e.Name, o.OrderID, o.CreatedOn, oi.Quantity,

I would like to convert or format this date,time to date only.

38      Oregon      1      2009-06-27 08:51:43.960      1      Oregon      0.264      0.000      0.176880      0.000000      0.67            .77             14      Name: Dennis West City: Eagle Point
0
Comment
Question by:westdh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 500 total points
ID: 24854924

SELECT CONVERT(varchar(10), o.CreatedOn, 120 ) CreatedOn
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 24854926
SELECT * FROM (SELECT  Distinct c.CustomerID,  e.Name, o.OrderID, CONVERT(varchar(10), o.CreatedOn, 120 ) CreatedOn , oi.Quantity ) a
0
 
LVL 60

Expert Comment

by:Kevin Cross
ID: 24855002
Just note that using convert you are changing the date to a string; therefore, if you still want to treat this value as a date you may want to consider what your need for removing time is.  If you need that just to have records created different times throughout a day to group together, then you can also use date functions like this to make the dates all as of midnight of date.

SELECT *
FROM (SELECT  Distinct c.CustomerID,  e.Name, o.OrderID, DATEADD(d, 0, DATEDIFF(d, 0, o.CreatedOn)) CreatedOn , oi.Quantity ) a
0
 
LVL 27

Expert Comment

by:Chris Luttrell
ID: 24855544
I agree with mwvisa1.
Also, why are you doing
Select * from (Select Distinct ...
This query raises red flags to me, maybe you should describe what you are doing and someone here can offer some good SQL practices advice.
0
 

Author Closing Comment

by:westdh
ID: 31603531
Solve it..Thanks
0

Featured Post

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

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

Audit has been really one of the more interesting, most useful, yet difficult to maintain topics in the history of SQL Server. In earlier versions of SQL people had very few options for auditing in SQL Server. It typically meant using SQL Trace …
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

707 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