SQL Query help

Dear expert

MS Query below shows a result with 2018-02-11 01:00:00:000, I would like to add a striping so it only shows 2018-02-11.

Any tips?

SELECT TOP 10 [Time]
FROM [Prod].[Data].[IncomingUpdate]
order by Time desc
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:

SELECT TOP 10 cast([Time] as date) [Time]
FROM [Prod].[Data].[IncomingUpdate]
order by 1 desc
Ares KurkluSoftware EngineerCommented:
You can try;

FROM [Prod].[Data].[IncomingUpdate]
order by Time desc

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mark WillsTopic AdvisorCommented:
Few different methods, probably depends on how you want to use it

Also depends on if you want the top 10 different [time]

SELECT TOP 10 [Time]
       , format([time],'yyyy-MM-dd') as Format_Time                   -- ends up as varchar
       , convert(char(10), [time],120) as convert_time                   -- ends up as varchar                 
       , cast([time] as date) as cast_time                                -- ends up as date
       , dateadd(d,0,datediff(d,0,[time])) as datediff_time                   -- remains datetime but gets rid of hours etc
FROM [Prod].[Data].[IncomingUpdate]
order by Time desc

Open in new window

Lots of ways to 'show' the format you want, but a fundamental difference in the datatype. Probably the cast as date is preferred because it gives you format but also preserves date construct. As Ryan had posted :)
WeTiAuthor Commented:
Thanks Ares got the result more correct so he will get more points. Thnx for other answers.
Jim HornMicrosoft SQL Server Data DudeCommented:
As an aside, [Time] is a poor choice of column name as it is also a data type and therefore a reserved word, which forces T-SQL developers to use square brackets [] surrounding it in code, which is one thing to potentially forget and throw an error.

And you'll confuse the hell out of your users with a column named [Time] that contains a date value with no time.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.