Glowworm27
Programmer
Hello all,
I have a hit counter that records when a page is hit. I only care about the hour that the page was hit. So I am trying to create a report that will display the time in 12 hour Am/Pm format. But the Datepart() function returns a number from 0 to 23 I want to convert that in the select statement using a Case, but get an error about select not being in the agregate function..
if there is a way to get the data in 12 hour format that would be great thanks.
George Oakes
CEO & President
COPS Software, Inc.
Programmer & Developer
.Net, WSS 3.0, SQL DBA
Check out this awsome .Net Resource!
I have a hit counter that records when a page is hit. I only care about the hour that the page was hit. So I am trying to create a report that will display the time in 12 hour Am/Pm format. But the Datepart() function returns a number from 0 to 23 I want to convert that in the select statement using a Case, but get an error about select not being in the agregate function..
Code:
Select Count(*) as HitCounter
, Case when Datepart(hh,DateTimeStamp) < 13 then (Convert(varchar(2), Datepart(hh,DateTimeStamp)) + 'AM')
Else (Convert(varchar(2), (Datepart(hh,DateTimeStamp) - 12)) + 'PM')
End as HitHour
From tblHits
Where CounterName = 'SearchInvoice'
Group By Datepart(hh,DateTimeStamp)
if there is a way to get the data in 12 hour format that would be great thanks.
George Oakes
CEO & President
COPS Software, Inc.
Programmer & Developer
.Net, WSS 3.0, SQL DBA
Check out this awsome .Net Resource!