Hi i need group the records based on the time stmap
datetime column
2011-11-23 06:08:50.000
2011-11-23 06:08:50.000
2011-11-23 06:21:06.000
2011-11-23 06:21:06.000
2011-11-23 06:21:06.000
2011-11-23 07:00:18.000
right now it displays like this when i do group by function
2011-11-23 06:08:50.000 2
2011-11-23 06:21:06.000 3
2011-11-23 07:00:18.000 1
ar per my result i need to get
2011-11-23 6
Try this:
This converts the time to a string matching pattern
YYYY-MM-DD HH, which seems to be what you want, e.g.'2012-01-31 12'.That format will also sort and compare in the natural way.
For a resolution of days, use varchar(10), hours varchar(13), minutes, use varchar(16), seconds varchar(19). Essentially you are truncating the string at the relevant point.