简体   繁体   中英

SSIS Date in derived column as yyyy-mm-dd format

I would need date in YYYY-MM-DD format in a ssis derived column,

i am using (DT_DATE)(DT_DBDATE)GETDATE() which is populating as 2013-05-24 00:00:00

Please suggest...

SSIS Derived Column expression variant:

(DT_STR, 4, 1252) DATEPART("yy" , GETDATE())  + "-" + 
RIGHT("0" + (DT_STR, 2, 1252) DATEPART("mm" , GETDATE()), 2)  + 
"-" + RIGHT("0" + (DT_STR, 2, 1252) DATEPART("dd" , GETDATE()), 2)

我通常使用unicode:

 SUBSTRING((DT_WSTR, 4)(GETDATE()), 1, 4)
(DT_WSTR,10)(DT_DBDATE)(GETDATE())

You're getting a time part to the date because you're casting to a type of "datetime" care-of the (DT_DATE) part of your expression. Pop that out and you should be gold. General formatting guidance:

Convert to YYYY-MM-DD...

(DT_WSTR, 30)(DT_DBDATE)@[System::StartTime]

Convert to YYYYMMDD...

REPLACE( (DT_WSTR, 30)(DT_DBDATE)@[System::StartTime], "-", "")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM