Take the 2-minute tour ×
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. It's 100% free, no registration required.

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

07/May/2012:00:01:49
07/May/2012:00:02:14
07/May/2012:00:02:26

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?

Thanks.

share|improve this question

1 Answer 1

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

 
discard

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.