I am using SQL Server 2008, I have time column (varchar) with time intervals 10 min basis. I want to display the time with half and hour basis..
The table (timeslot) has this data:
time
-----
11:10 AM
11:20 AM
11:30 AM
11:40 AM
11:50 AM
12:00 PM
12:10 PM
12:20 PM
12:30 PM
12:40 PM
12:50 PM
01:00 PM
01:10 PM
01:20 PM
And I want to display this output:
time
-----
11:00 AM
11:30 AM
12:00 PM
12:30 PM
01:00 PM
01:30 PM
Can anybody help me on this? thanks in advance…
Try something like this:
Of course – if you used the appropriate datatype of
TIMEfor your column in the first place, you could save yourself theCAST(.. as TIME)construct and things would be even easier….Update: if you need to order by your time – use this:
PS: it’s also a really bad idea to name a column
time– since that’s a reserved keyword (for the datatype) in SQL Server 2008 …..