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
 Adding a date coloumn
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

14 Posts

Posted - 05/02/2014 :  12:07:23  Show Profile  Reply with Quote
hi guys

i have a query like following


DECLARE @StartDate DateTime
DECLARE @EndDate DateTime

SET @StartDate = CAST (DATEDIFF(d, 0, DATEADD(d, 1 - day(getdate()), getdate()))as datetime)
SET @EndDate = GetDate()

/*Convert(DateTime,Floor(Cast((DateTime) as Float)),0) AS SummaryDate,
		Nodes.Caption AS NodeName,
		Nodes.VendorIcon AS Vendor_Icon,
		Interfaces.Caption AS Interface_Caption,
		Interfaces.InterfaceIcon AS Interface_Icon,
FROM Nodes
INNER JOIN Interfaces ON Nodes.NodeID = Interfaces.NodeID
	SELECT	InterfaceID,
			 dbo.GetInBps95th(InterfaceID, @StartDate, @EndDate) AS Maxbps_In95,
			 dbo.GetOutBps95th(InterfaceID, @StartDate, @EndDate) AS Maxbps_Out95,
			 dbo.GetMaxBps95th(InterfaceID, @StartDate, @EndDate) AS Maxbps_95
	FROM InterfaceTraffic
	WHERE InterfaceTraffic.DateTime >= @StartDate AND InterfaceTraffic.DateTime <= @EndDate
	GROUP BY InterfaceID
) TrafficStat
ON Interfaces.InterfaceID = TrafficStat.InterfaceID /*inner join InterfaceTraffic on trafficstat.InterfaceID = InterfaceTraffic.InterfaceID
   (Interfaces.Caption LIKE '%TO LA%') OR 
   (Interfaces.Caption LIKE '%TKM%') OR 
   (Interfaces.Caption LIKE '%TLKM%') OR 
   (Interfaces.Caption LIKE '%XL%') OR 
   (Interfaces.Caption LIKE '%TELKOM%') OR 
   (Interfaces.Caption LIKE '%MPLS%')

/*GROUP BY Convert(DateTime,Floor(Cast((DateTime) as Float)),0), interfaces.InterfaceID, nodes.NodeID, nodes.Caption, nodes.VendorIcon, interfaces.caption, Interfaces.InterfaceIcon, trafficstat.Maxbps_95, trafficstat.Maxbps_In95, TrafficStat.Maxbps_Out95
ORDER BY NodeName, Interface_Caption

and when i execute it, it gave a return that i expected, but then i want to add a date coloumn on the first coloumn, i have tried many thinks but still doesnt gave me what i want

is there any idea ??

Flowing Fount of Yak Knowledge

2780 Posts

Posted - 05/02/2014 :  12:18:01  Show Profile  Reply with Quote
Where do you want to get the date from?
Go to Top of Page

Flowing Fount of Yak Knowledge

4614 Posts

Posted - 05/02/2014 :  12:20:43  Show Profile  Reply with Quote
What is not working? Are you getting an error or unexpected results? Do you really have a column called DateTime? It's hard to tell what you trying to do because you've commented out most the query.

If you want to post your DDL, Sample data and expected output we can help you better. Here are some links that can help you provide that:
Go to Top of Page

Starting Member

14 Posts

Posted - 05/02/2014 :  14:02:06  Show Profile  Reply with Quote
thanks for all reply

the query above only give me a result without any coloumn of date, and i want to add it, for instance, i would like to have a return as following

Date : 03/05/2014
InterfaceID : 309
NodeID : 380
NodeName : France
VendorIcon : Cisco
Interface Caption : Interface FastEthernet 1/0
Interface Icon : FastEthernet
MaxBps_In95 : 3892 bps
MaxBps_Out95 : 4932 bps
MaxBps_Max95 : 5540 bps

but what i get when execute the query i dont get Date coloumn on the result, and i need that coloumn to be added into the result for report purpose
Go to Top of Page

Flowing Fount of Yak Knowledge

4614 Posts

Posted - 05/02/2014 :  14:26:18  Show Profile  Reply with Quote
I hate to be captain obvious, but did you uncomment the column you want?
Go to Top of Page

Starting Member

14 Posts

Posted - 05/05/2014 :  03:03:28  Show Profile  Reply with Quote
yes, if i uncomment the coloumn i want, the process query never stop and need to be stop forcely,

any idea ??
Go to Top of Page
  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.04 seconds. Powered By: Snitz Forums 2000