[thelist] SQL Query - Select Distinct Dates in Date/Time Field

Ben Dyer ben_dyer at imaginuity.com
Fri Feb 22 10:38:01 CST 2002


I have a table with a date/time stamp field in it.  I'm trying to select
the distinct *dates* (not date/times) from the database.

For example, in this table:

   dtJoined
   2/20/2002 1:53:03 PM
   2/20/2002 3:14:36 PM
   2/21/2002 7:08:00 AM
   2/22/2002 10:19:53 AM
   2/22/2002 6:45:27 PM

I want to return three records: 2/20/2002, 2/21/2002 and 2/22/2002.

This was the query I was trying on a coworker's recommendation:

SELECT          DISTINCT CONVERT(varchar, dtJoined, 101) AS dtJoinedDate
               , dtJoined
FROM            tblTable
ORDER BY        dtJoined

...but it doesn't select distinct dates.

Does anyone have any suggestions?  I'm kind of at a loss here.

Thanks.

--Ben

Ben Dyer, Senior Internet Developer, Imaginuity Interactive
http://www.imaginuity.com/

     If you save the world too often, it begins to expect it.
-----------------------------------------------------------------
   http://members.evolt.org/OKolzig37/     http://www.evolt.org/




More information about the thelist mailing list