Solved

How can I convert this to date only

Posted on 2009-07-14
6
203 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
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 59

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 26

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

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.

Question has a verified solution.

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

This is basically a blog post I wrote recently. I've found that SARGability is poorly understood, and since many people don't read blogs, I figured I'd post it here as an article. SARGable is an adjective in SQL that means that an item can be fou…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

920 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

15 Experts available now in Live!

Get 1:1 Help Now