| Author | Topic | 
                            
                                    | varunmStarting Member
 
 
                                        25 Posts | 
                                            
                                            |  Posted - 2006-09-21 : 11:43:23 
 |  
                                            | hello Members,I need only date from datetime.when i select dt from table(where dt has datatype datetime) it shows date and time.Please help me,i tried cast but throws me error. |  | 
       
                            
                       
                          
                            
                                    | TGMaster Smack Fu Yak Hacker
 
 
                                    6065 Posts |  | 
                            
                       
                          
                            
                                    | madhivananPremature Yak Congratulator
 
 
                                    22864 Posts | 
                                        
                                          |  Posted - 2006-09-21 : 12:13:47 
 |  
                                          | Select DateAdd(day,DateDiff(day,0,Datecol),0) as Date_Only from yourTableMadhivananFailing to plan is Planning to fail |  
                                          |  |  | 
                            
                       
                          
                            
                                    | varunmStarting Member
 
 
                                    25 Posts | 
                                        
                                          |  Posted - 2006-09-21 : 13:15:51 
 |  
                                          | I made it ,but can you will be clear.Because I am new to SQL SERVER. |  
                                          |  |  | 
                            
                       
                          
                            
                                    | madhivananPremature Yak Congratulator
 
 
                                    22864 Posts | 
                                        
                                          |  Posted - 2006-09-21 : 21:01:57 
 |  
                                          | quote:What did you make?MadhivananFailing to plan is Planning to failOriginally posted by varunm
 I made it ,but can you will be clear.Because I am new to SQL SERVER.
 
 |  
                                          |  |  | 
                            
                       
                          
                            
                                    | Michael Valentine JonesYak DBA Kernel (pronounced Colonel)
 
 
                                    7020 Posts |  | 
                            
                       
                          
                            
                                    | varunmStarting Member
 
 
                                    25 Posts | 
                                        
                                          |  Posted - 2006-09-21 : 21:44:59 
 |  
                                          | Members,I tried to change the datetime to only date.Its easy:select convert(varchar,'columnname',101') |  
                                          |  |  | 
                            
                       
                          
                            
                                    | DonAtWorkMaster Smack Fu Yak Hacker
 
 
                                    2167 Posts | 
                                        
                                          |  Posted - 2006-09-22 : 13:42:54 
 |  
                                          | quote:Too bad your solution is no longer a datetime.Madhi gave you the right answer.Select DateAdd(day,DateDiff(day,0,Datecol),0) as Date_Only[Signature]For fast help, follow this link:http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxLearn SQLhttp://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.aspMembers,I tried to change the datetime to only date.Its easy:select convert(varchar,'columnname',101')
 
 |  
                                          |  |  | 
                            
                       
                          
                            
                                    | madhivananPremature Yak Congratulator
 
 
                                    22864 Posts | 
                                        
                                          |  Posted - 2006-09-23 : 08:49:43 
 |  
                                          | quote:Also,If you use front end application, use the format function thereMadhivananFailing to plan is Planning to failOriginally posted by varunm
 Members,I tried to change the datetime to only date.Its easy:select convert(varchar,'columnname',101')
 
 |  
                                          |  |  | 
                            
                            
                                |  |