Please start any new threads on our new 
    site at https://forums.sqlteam.com.  We've got lots of great SQL Server
    experts to answer whatever question you can come up with.
    
        | 
                
                    | 
                            
                                | Author | Topic |  
                                    | Eagle_f90Constraint Violating Yak Guru
 
 
                                        424 Posts | 
                                            
                                            |  Posted - 2013-07-01 : 16:21:23 
 |  
                                            | I need to write a IF statement that looks at a DateTime variable which holds a full date and time (i.e. 07/01/2013 1619 Hours) and see if that variable happened after a certain time of day (i.e. 0100 hours). Is there an easy and efficient way of doing this? I originally though about splitting out the time format and then converting to military time then doing the compare but that seems overly complicated.-- If I get used to envying others...Those things about my self I pride will slowly fade away.-Stellvia |  |  
                                    | James KMaster Smack Fu Yak Hacker
 
 
                                    3873 Posts | 
                                        
                                          |  Posted - 2013-07-01 : 16:48:09 
 |  
                                          | You can use the datepart function, like in this example: DECLARE @x DATETIME = GETDATE();IF DATEPART(HOUR,@x) > 1 	PRINT 'Yes, it is  1:00 AM or later'ELSE	PRINT 'No, it is not yet 1:00 AM' |  
                                          |  |  |  
                                    | Eagle_f90Constraint Violating Yak Guru
 
 
                                    424 Posts | 
                                        
                                          |  Posted - 2013-07-01 : 16:48:45 
 |  
                                          | Again, you come to my rescue. Thanks-- If I get used to envying others...Those things about my self I pride will slowly fade away.-Stellvia |  
                                          |  |  |  
                                    | James KMaster Smack Fu Yak Hacker
 
 
                                    3873 Posts | 
                                        
                                          |  Posted - 2013-07-01 : 17:33:01 
 |  
                                          | Again  , you are very welcome - glad to help. |  
                                          |  |  |  
                                |  |  |  |