SSIS Conditional Split small problem comparing dates

Hi All,

I have an SSIS package that i'm trying to write that is pretty basic: reads from a csv, I want to filter the incoming rows to only insert rows from yesterday, then load into db.

I have a Flat File Source --> Conditional Split --> OLE DB destination

In the Conditional Split however, I am having problems trying to create the condition that will only insert rows where [date] column is of yesterday.

The [date] column however, is a varchar column in the format yyyy-mm-dd so I figure I have to convert/cast it to a date or datetime.

I tried using this but I cant get it non-red!

DATEPART( "DAY", CAST([Date] as datetime)  ) ==  DATEPART( "DAY", getdate() -1)

The error is:

Attempt to parse the expression ,,, failed. The expression might contain an incomplete token, invalid token or an invalid element.

if I take that and put it in a select, it works fine, but within the Conditional Split I don't quite know the proper syntax

Thanks in advance

January 29th, 2015 9:27pm

yyyy-mm-dd is the ISO 8006 format should be convertible easy with SSIS Expression (not CAST ! of T-SQL)

as

(DT_DATE)(Column_1) < DATEADD( datepart, integer, date )

Free Windows Admin Tool Kit Click here and download it now
January 29th, 2015 11:04pm

yyyy-mm-dd is the ISO 8006 format should be convertible easy with SSIS Expression (not CAST ! of T-SQL)

as

(DT_DATE)(Column_1) < DATEADD( datepart, integer, date )

January 29th, 2015 11:14pm

yyyy-mm-dd is the ISO 8006 format should be convertible easy with SSIS Expression (not CAST ! of T-SQL)

as

(DT_DATE)(Column_1) < DATEADD( datepart, integer, date )

Free Windows Admin Tool Kit Click here and download it now
January 31st, 2015 10:10am

I want to filter the incoming rows to only insert rows from yesterday, then load into db.

As per above statement what you're having in expression is wrong as its only looking for day part alone. It should be this

(DT_DATE)[Date] ==(DT_DATE)(DT_DBDATE)DATEADD("DAY",-1,GETDATE())

January 31st, 2015 11:49am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics