SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 help needed with sql string in vba and timestamp
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

punkaholic
Starting Member

Belgium
1 Posts

Posted - 11/05/2013 :  07:56:09  Show Profile  Reply with Quote
Hi I'm new to SQL. I'm using VBA to extract data from the SQL 2008 server and put it in an excel sheet. I'm averaging the data per hour with the intention to make a weekly graph out of it. Unfortunately at some timeperiods no data has been recorded and thus no timestamp has been created. However I still need those timestamps to make a graph with a continuous time interval of an hour. Below is an example of such a timegap and also the sql string I am using. Is there a way to fill in this timegap?

kind regards,

MP2 25/10/2013 23:00
MP2 26/10/2013 0:00
MP2 26/10/2013 2:39
MP2 26/10/2013 3:00



"SELECT MonitoringLogs.MPName,Min(MonitoringLogs.TimeStamp)as Timestamp,Avg(MonitoringLogs.Easting)as Easting, &
Avg(MonitoringLogs.Northing)as Northing,Avg(MonitoringLogs.Height)as Height,Avg(MonitoringLogs.Pitch)as Pitch,Avg(MonitoringLogs.Roll)as Roll & _
FROM MonitoringLogs & _
WHERE MonitoringLogs.TimeStamp>= {ts " & Format(startdate, "\'yyyy-mm-dd hh:mm:ss\'") & " }& _
AND MonitoringLogs.TimeStamp< {ts " & Format(enddate, "\'yyyy-mm-dd hh:mm:ss\'") & " }& _
AND MonitoringLogs.Fix = 4 & _
GROUP BY MONTH(MonitoringLogs.TimeStamp),DAY(MonitoringLogs.TimeStamp),{fn HOUR(MonitoringLogs.TimeStamp)},MonitoringLogs.MPName & _
ORDER BY MonitoringLogs.MPName,Timestamp "
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000