We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


Group by in datagrid

running32 asked
Medium Priority
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 "
Watch Question

Software Engineer
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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.