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 |  
                                    | sikni8Starting Member
 
 
                                        2 Posts | 
                                            
                                            |  Posted - 2014-06-19 : 17:07:34 
 |  
                                            | I have the following SSIS expression:Right("0" + (DT_STR,4,1252) DatePart("m",getdate()),2) + RIGHT("0" + (DT_STR,4,1252) DatePart("yyyy",getdate()),2)which gives me 0614.How can I change the month code so it always gives me the previous month's number? |  |  
                                    | tkizerAlmighty SQL Goddess
 
 
                                    38200 Posts | 
                                        
                                          |  Posted - 2014-06-19 : 17:13:32 
 |  
                                          | Just subtract 1 from the datepart month calculation.Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |  
                                          |  |  |  
                                    | sikni8Starting Member
 
 
                                    2 Posts | 
                                        
                                          |  Posted - 2014-06-20 : 09:14:39 
 |  
                                          | I did that and it didn't work :/ |  
                                          |  |  |  
                                    | tkizerAlmighty SQL Goddess
 
 
                                    38200 Posts | 
                                        
                                          |  Posted - 2014-06-20 : 12:44:20 
 |  
                                          | This doesn't work?: DatePart("m",getdate()),2)-1Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |  
                                          |  |  |  
                                |  |  |  |