| Author | Topic | 
                            
                                    | sz1Aged Yak Warrior
 
 
                                        555 Posts | 
                                            
                                            |  Posted - 2010-10-29 : 10:25:56 
 |  
                                            | Help, why is date fields so awkward.How do I remove the date fields below to make the offeringTime = today, so it just refreshes the select statement for today only without input.Basically this need to: (OfferingTime >= '2010/10/29 08:00:00')be (OfferingTime = TODAY)ThanksSELECT COUNT(CallID) AS TotalRedirectsFROM         CallsWHERE     (DeviceType = 'A') AND (DisconnectedTime IS NOT NULL) AND (OfferingTime >= '2010/10/29 08:00:00') AND (OfferingTime <= '2010/10/29 18:00:00') AND (RedirectingIDName = 'MyFQ(5555)')GO |  | 
       
                            
                       
                          
                            
                                    | robvolkMost Valuable Yak
 
 
                                    15732 Posts | 
                                        
                                          |  Posted - 2010-10-29 : 10:30:47 
 |  
                                          | There's a number of ways, but these posts have the best solutions:http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=64755http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=64759These and other date-related threads are summarized here:http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=64762 |  
                                          |  |  | 
                            
                       
                          
                            
                                    | Michael Valentine JonesYak DBA Kernel (pronounced Colonel)
 
 
                                    7020 Posts | 
                                        
                                          |  Posted - 2010-10-29 : 11:09:44 
 |  
                                          | [code]select	TodayAt0800 = dateadd(dd,dateDiff(dd,0,getdate()),'08:00'),	TodayAt1800 = dateadd(dd,dateDiff(dd,0,getdate()),'18:00')[/code]Results:[code]TodayAt0800             TodayAt1800----------------------- -----------------------2010-10-29 08:00:00.000 2010-10-29 18:00:00.000[/code]CODO ERGO SUM |  
                                          |  |  | 
                            
                       
                          
                            
                                    | webfredMaster Smack Fu Yak Hacker
 
 
                                    8781 Posts | 
                                        
                                          |  Posted - 2010-10-29 : 11:13:00 
 |  
                                          | That's cool!I never would have the idea to try that - nice to know now  No, you're never too old to Yak'n'Roll if you're too young to die.
 |  
                                          |  |  | 
                            
                       
                          
                            
                                    | sz1Aged Yak Warrior
 
 
                                    555 Posts | 
                                        
                                          |  Posted - 2010-10-29 : 11:33:12 
 |  
                                          | so you're saying this then:SELECT COUNT(CallID) AS TotalRedirects,TODAYAT0800 = dateadd(dd,dateDiff(dd,0,getdate()),'08:00'),TODAYAT1800 = dateadd(dd,dateDiff(dd,0,getdate()),'18:00')FROM         CallsWHERE     (DeviceType = 'A') AND (DisconnectedTime IS NOT NULL) AND (RedirectingIDName = 'MyFQ(5555)')GODidn't know you could do field oike this TODAYAT0800, how does SQL call this?Thankssz1 |  
                                          |  |  | 
                            
                       
                          
                            
                                    | Michael Valentine JonesYak DBA Kernel (pronounced Colonel)
 
 
                                    7020 Posts | 
                                        
                                          |  Posted - 2010-10-29 : 11:41:29 
 |  
                                          | No, I was showing an example of how to find the DATETIME values that you wanted to use in your WHERE clause: Today at 08:00 and Today at 18:00.CODO ERGO SUM |  
                                          |  |  | 
                            
                       
                          
                            
                                    | sz1Aged Yak Warrior
 
 
                                    555 Posts | 
                                        
                                          |  Posted - 2010-10-29 : 11:49:15 
 |  
                                          | Ok, thanks will try this out. |  
                                          |  |  | 
                            
                       
                          
                            
                                    | sz1Aged Yak Warrior
 
 
                                    555 Posts | 
                                        
                                          |  Posted - 2010-10-29 : 11:59:26 
 |  
                                          | Cool nice one pal.It works, you guys are groovy...SELECT COUNT(CallID) AS TotalRedirectsFROM         CallsWHERE     (DeviceType = 'A') AND (DisconnectedTime IS NOT NULL) AND OfferingTime >= dateadd(dd,dateDiff(dd,0,getdate()),'08:00')AND OfferingTime <= dateadd(dd,dateDiff(dd,0,getdate()),'18:00')AND (RedirectingIDName = 'MyFQ(5555)')GO |  
                                          |  |  | 
                            
                            
                                |  |