Solved

How to select DISTINCT dates from a Date/Time field

Posted on 2000-04-28
2
493 Views
Last Modified: 2010-05-18
I'm trying to select distinct dates from a Date/Time field
Tried something like

SELECT DISTINCT left(myDate,11) AS dateList FROM myTable

Unfortunately, it returns the date converted to string, no good.

Any right way of doing this?

Thanks

Ion
0
Comment
Question by:iamari
2 Comments
 
LVL 4

Accepted Solution

by:
Gustavo Perez Buenrostro earned 100 total points
Comment Utility
Try next query and post your opinion:

select distinct convert(datetime,convert(varchar,myDate,112)) from myTable
0
 
LVL 2

Author Comment

by:iamari
Comment Utility
Thanks a alot, works like a charm!

Ion
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to shrink a transaction log file down to a reasonable size.

762 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

11 Experts available now in Live!

Get 1:1 Help Now