JBOSS 点滴

丰丰的博客

SQL:已知当前日期求上个月年月(如已知'2006-05'求'200604'

  declare @lastmonth datetime,         
          @balance_yymm char(7), --本月年月(如YY-MM)        
          @lastchar   char(7)    --上月年月(如YYMM)     
  set     @lastmonth=dateadd(month,-1,@balance_date)         
  set     @lastchar=convert(char(7),@lastmonth,126)         
  set     @lastchar=left(@lastchar,4)+substring(@lastchar,6,2)  

posted on 2006-12-22 14:24 半导体 阅读(1588) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: