insert into #temp select '2011-05-16 13:35:54.930','2011-05-16 13:00:54.930' union all select '2011-05-16 22:45:54.930','2011-05-16 13:5:54.930' union all select '2011-05-16 13:58:54.930','2011-05-16 13:15:54.930' union all select '2011-05-16 13:30:54.930','2011-05-16 13:29:54.930'
select * from #temp -- Expected output: I need to convert field to next half an hour (ex: 12:35:00.000 to 13:00:00.000 ond 12:12:00.000 to 12:30:00.0000)
select dateadd(minute,30,dateadd(minute,(datediff(minute,0,startdate)/30)*30,0))startdate ,dateadd(minute,30,dateadd(minute,(datediff(minute,0,enddate)/30)*30,0))enddate from #temp