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  | 
                             
                            
                                    | 
                                         bmanning100 
                                        Starting Member 
                                         
                                        
                                        7 Posts  | 
                                        
                                        
                                            
                                            
                                             Posted - 2015-02-17 : 15:37:15
                                            
  | 
                                             
                                            
                                            | I need code help converting Military time to datetime SQL Server. Example below.27JAN2015:22:15:00.26 bm | 
                                             
                                         
                                     | 
                             
       
                            
                       
                          
                            
                                    | 
                                     Bustaz Kool 
                                    Master Smack Fu Yak Hacker 
                                     
                                    
                                    1834 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2015-02-17 : 19:08:28
                                          
  | 
                                         
                                        
                                          Are you sure that there is a colon between the date and the time portions of your string? If I replace it with a space...select cast('27JAN2015 22:15:00.26' as datetime)Seems to return the proper results. Those who will not reason, are bigots, those who cannot, are fools, and those who dare not, are slaves. -Lord Byron, poet (1788-1824)  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     bmanning100 
                                    Starting Member 
                                     
                                    
                                    7 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2015-02-17 : 19:20:49
                                          
  | 
                                         
                                        
                                          | Yes you are correct no space betweend date and time. but I want to change 22:15:00.26 to 10:15:00.26pm. Is this possible.bm  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     ScottPletcher 
                                    Aged Yak Warrior 
                                     
                                    
                                    550 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2015-02-18 : 15:23:08
                                          
  | 
                                         
                                        
                                          Convert it to format 109, like so:SELECT CONVERT(varchar(30), col1, 109)FROM (    SELECT CAST('27JAN2015 22:15:00.26' AS datetime) AS col1) AS test_data  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                            
                                | 
                                    
                                      
                                     
                                    
                                 | 
                             
                         
                     | 
                 
             
         |