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  | 
                             
                            
                                    | 
                                         s.mirzaei1990 
                                        Starting Member 
                                         
                                        
                                        12 Posts  | 
                                        
                                        
                                            
                                            
                                             Posted - 2014-08-05 : 15:38:18
                                            
  | 
                                             
                                            
                                            | hi i have a database sql,type of year is decimal(5,0),type of month and day are smallint, i wanna compare 2 dates.A date must be greater than another date.i need a function for comparing.who can help me? please. | 
                                             
                                         
                                     | 
                             
       
                            
                       
                          
                            
                                    | 
                                     tkizer 
                                    Almighty SQL Goddess 
                                     
                                    
                                    38200 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2014-08-05 : 15:40:13
                                          
  | 
                                         
                                        
                                          | I would start by changing the table design so that you have a date column instead of 3 different columns. Even if you keep them at 3 different columns, I don't see why you'd use decimal(5,0) for the year. Show us some sample data and expected output.Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     Bustaz Kool 
                                    Master Smack Fu Yak Hacker 
                                     
                                    
                                    1834 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2014-08-05 : 15:51:26
                                          
  | 
                                         
                                        
                                          Why are you not using the Date, Time or Datetime data types?where case   when a.Year > b.year then 1   when a.Year < b.year then 0   when a.month > b.month then 1   when a.month < b.month then 0   when a.day > b.day then 1   else 0   end = 1 Ugh! Too often we enjoy the comfort of opinion without the discomfort of thought. - John F. Kennedy  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     s.mirzaei1990 
                                    Starting Member 
                                     
                                    
                                    12 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2014-08-05 : 15:52:38
                                          
  | 
                                         
                                        
                                          | cause my date is for persian calender and my master said these types are better.  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                       
                          
                            
                                    | 
                                     s.mirzaei1990 
                                    Starting Member 
                                     
                                    
                                    12 Posts  | 
                                    
                                      
                                        
                                          
                                           
                                            Posted - 2014-08-05 : 15:57:29
                                          
  | 
                                         
                                        
                                          | gratefull  | 
                                         
                                        
                                            | 
                                         
                                       
                                     | 
                                   
                            
                            
                                | 
                                    
                                      
                                     
                                    
                                 | 
                             
                         
                     | 
                 
             
         |