一个月的SSIS表达式构建器

时间:2016-07-19 15:56:55

标签: sql visual-studio ssis

我正在努力获得2016年6月的评估价值'在microsoft visual studio中的表达式构建器中获取ssis包。

我有一个代码

(DT_WSTR,4)MONTH( DATEADD( "month", -1, getdate()))

仅提供值' 6'

我怎样才能改变它给我' Jun'

3 个答案:

答案 0 :(得分:0)

这应该有效:

(MONTH(RowDate) == 1 ? "Jan" : MONTH(RowDate) == 2 ? "Feb" : MONTH(RowDate) == 3 ? "Mar" : 
  MONTH(RowDate) == 4 ? "Apr" : MONTH(RowDate) == 5 ? "May" : MONTH(RowDate) == 6 ? "Jun" : 
  MONTH(RowDate) == 7 ? "Jul" : MONTH(RowDate) == 8 ? "Aug" : MONTH(RowDate) == 9 ? "Sep" : 
  MONTH(RowDate) == 10 ? "Oct" : MONTH(RowDate) == 11 ? "Nov" : MONTH(RowDate) == 12 ? "Dec" : 
  "ERR") + " (" + (DT_WSTR,4)YEAR(RowDate) + ")"

http://www.sqlis.com/sqlis/post/Expression-Date-Functions.aspx

答案 1 :(得分:0)

SELECT AR_SQ.SYMBOL, AR_SQ.NAME, AR_SQ.LAST, FF_PS.SECTOR,
  FF_PS.SECTOR_TAGS, RS.LAST_10_DAYS, RS.YTD_PERF, RS.TRADE_DATE 
FROM AR_STOCK_QUOTE AR_SQ 
INNER JOIN FF_HISTORICAL_STOCK_PRICE RS
  ON RS.SYMBOL = AR_SQ.SYMBOL
INNER JOIN (
  SYMBOL, MAX(TRADE_DATE) AS TRADE_DATE
  FROM FF_HISTORICAL_STOCK_PRICE
  GROUP BY SYMBOL 
) MAXRS 
  ON RS.SYMBOL = MAXRS.SYMBOL AND RS.TRADE_DATE = MAXRS.TRADE_DATE
JOIN FF_PRIMARY_STOCK_TABLE FF_PS on FF_PS.SYMBOL = AR_SQ.SYMBOL 
WHERE RS.SYMBOL = 'ADI'

它应该去,也删除一年中的月份。

答案 2 :(得分:0)

要获取YearMonth,如果文件名为FileNameYYYY_MM_DD.xls,我们可以使用以下代码:

(DT_WSTR,4)YEAR(DATEADD( "MM", -1,  (DT_DATE) Replace (SUBSTRING( @[User::FileName]  , FINDSTRING(@[User::FileName], "2017", 1) , 10 ), "_", "-" ))+RIGHT("00"+(DT_WSTR,2)MONTH(DATEADD( "MM", -1,  (DT_DATE) REPLACE(SUBSTRING( @[User::FileName]  , FINDSTRING(@[User::FileName], "2017", 1) , 10 ), "_", "-" )),2)