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  | 
                             
                            
                                    | 
                                         stanlyn 
                                        Starting Member 
                                         
                                        
                                        3 Posts  | 
                                        
                                        
                                            
                                            
                                             Posted - 2015-02-07 : 06:36:06
                                            
  | 
                                             
                                            
                                            | Hi,How do I get the reverse and translate this command?CAST(0x0000A433009CCB10 AS DateTime)Thanks,StanleyStanley Barnett | 
                                             
                                         
                                     | 
                             
       
                            
                       
                          
                            
                                    | 
                                     gbritton 
                                    Master Smack Fu Yak Hacker 
                                     
                                    
                                    2780 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2015-02-07 : 10:22:43
                                          
  | 
                                         
                                        
                                          | e.g. select cast(getdate() as varbinary(100))  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     stanlyn 
                                    Starting Member 
                                     
                                    
                                    3 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2015-02-07 : 15:23:28
                                          
  | 
                                         
                                        
                                          | Hi gbritton,Sorry I do not understand how your command relates to the one I posted...  Here is the full command that I'm trying to get the reverse of...INSERT [dbo].[COUNTRY] ([ID], [NAME], [TA_ZIP_CODE], [CREATE_DATE], [CREATE_USER]) VALUES (1, N'USA', N'99999', CAST(0xB4360B00 AS Date), N'2')The field ""create_date" in table "country" is being filled with the results of "CAST(0xB4360B00 AS Date)"...So, how do I process that field's data to get the date back, (hence the reverse)?Thanks,StanleyUpdate...After checking the field's data type, it is "date" and the command above is something like a backup command that iterates the table building one of these for each row.  Therefore, is it safe to assume that the "create_date" field actually contains an english readable date of type date, but has to be converted to a string so it can be used in an insert command.   When reading the date field for use in the insert command a command something like case(create_date as string) would return "0xB4360B00" for use in the insert string above.Comments please...  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     gbritton 
                                    Master Smack Fu Yak Hacker 
                                     
                                    
                                    2780 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2015-02-07 : 16:52:38
                                          
  | 
                                         
                                        
                                          | your original query casts a varbiary as a date. the reverse is to cast a date as a varbinary. That's what I showed you how to do using the current date as an example.  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     stanlyn 
                                    Starting Member 
                                     
                                    
                                    3 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2015-02-07 : 22:19:37
                                          
  | 
                                         
                                        
                                          | Hi gbritton,OK, so my assumption statement above would be correct if I change my reference of a string to a binary instead??  Is my description of whats going on correct?Thanks,StanleyStanley Barnett  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     gbritton 
                                    Master Smack Fu Yak Hacker 
                                     
                                    
                                    2780 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2015-02-08 : 14:17:52
                                          
  | 
                                         
                                        
                                          | " is it safe to assume that the "create_date" field actually contains an english readable date of type date, but has to be converted to a string so it can be used in an insert command."No, this assumption is false.  you do not have to convert a date to a string to insert it into a table UNLESS the column in the table to which the date is to be inserted is not compatible with a date type.  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     ScottPletcher 
                                    Aged Yak Warrior 
                                     
                                    
                                    550 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2015-02-09 : 14:30:44
                                          
  | 
                                         
                                        
                                          | Just get rid of that monstrosity.  Why on earth is a binary value being translated to a datetime??  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                            
                                | 
                                    
                                      
                                     
                                    
                                 | 
                             
                         
                     | 
                 
             
         |   
     
     
            
              
	     |  
		
			
     
          
		 |