Query Help - Distinct Row with Date Portion of a DateTime

G

Guest

I have a table with a DateTime column and both the date and time portions of
the field are used in the entries. But I want to write a query that'll do the
following:

Get a list of each distinct DATE from all of the rows of the DateTime
column. So, for example, let's say the column is named "PurchaseDate", and
some of the values look like:

PurchaseDate
1/12/2006 3:25pm
1/12/2006 6:45pm
3/3/2006 12:05am
3/3/2006 1:22am

I'd like the result of this query (for this example) to be a list as follows:

DistinctDates
1/12/2006
3/3/2006

I know this is more of a SQL question than an ADO question but... help?

Alex
 
K

Kevin Yu [MSFT]

Hi Alex,

I agree with Theo that we can use the CONVERT function in TSQL to achieve
this in a SQL server query. However, your data is in a DataTable.

In this case, I think you have 2 options.

1. Update the data into database, and do the query on SQL server.
2. Write a method that goes through all the rows and selects out the
distinct dates.

Kevin Yu
Microsoft Online Community Support

============================================================================
==========================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
============================================================================
==========================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top