Group by in datagrid

Posted on 2006-03-31
Last Modified: 2009-12-16
I have a query that returns to me the last 3 days and this data is written to a datagrid.  This is working.  The only problem is that I would like to group it by date so that the I can get all information for one date on one line.

Currently it is displayed at

IN Date                         Out Date
03/30/2006 8:00 AM       03/30/2006  12:00 PM
03/30/2006 1:00 PM       03/30/2006    5:00 PM

I would like it to display as, the fields in the database are datatime.  Thank you

Date           InTime      OutTime      InTime       OutTime                      
03/30/2006 8:00 AM    12:00 PM     1:00 PM     5:00 PM

**********current sql query *************
 objCmd.CommandText = "select eh.recordid, firstname + ' ' +  lastname as name, timein, timeout from employeehours as eh inner join employeelist as el on eh.employeeid = el.employeeid where firstname = 'Justine' and lastname = 'Cleary' and timein  > CONVERT(datetime, '" & strCurrentdate & "', 102) order by timein "
Question by:running32
    1 Comment
    LVL 9

    Accepted Solution

    for getting date and time fields try doing this..

    select INDate as [Date],
              substring(convert(varchar,InDate,12,8)) as Intime,....similarly the rest..

    tell me if this works

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    I have developed many web applications with asp & and to add and use a dropdownlist was always a very simple task, but with the new, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
    In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    745 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

    18 Experts available now in Live!

    Get 1:1 Help Now