Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
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
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

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  
 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.02 seconds. Powered By: Snitz Forums 2000