Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a various date times stored as strings in my sqlserver database.


This column is called datetimesent and it is quite easy to select group by on it. For example:

SELECT DateTimeSent, COUNT(*) FROM MyTable where group by DateTimeSent

This will group be every second. What I'd like to do is group by every ten seconds, so instead of grouping by the entire string, group by all of it except last letter. How do I do this?


share|improve this question

You should consider the use of datetime instead but this will do what you want.

group by left(DateTimeSent, 19)
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.