Solved

How can I convert this to date only

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

     When we have to pass multiple rows of data to SQL Server, the developers either have to send one row at a time or come up with other workarounds to meet requirements like using XML to pass data, which is complex and tedious to use. There is a …
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

706 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

19 Experts available now in Live!

Get 1:1 Help Now