Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

changing datetime column to hourly time

$
0
0

Dear All,

I have a script that generates a memory report every 5 minutes. One of the columns is DATETIME, which gives the date and time of the memory collected every 5 minutes. I am asked to provide an hourly report instead of every 5 minutes. Is there any way I can change this column from every 5 minutes to every hour in an ad-hoc query? Bellow is the query I tried but it does not work:

SELECTCONVERT(VARCHAR(30),DATEADD(hour,1,[TimeLogged]), 109) AS [HourlyReport]
, [Memory_Used_MB]
, [Total_Physical_Memory_MB]
, [Memory_Used_In_%]
FROM[Table].[dbo].[MemoryUsage]
WHERE[TimeLogged] > '20140604'--change this to today's date
GROUP BY[Memory_Used_In_MB], [Total_Physical_Memory_In_MB], [Memory_Used_In_%],[HourlyReport]
GO

Thanks,

Daniel. 


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>