December 8, 2011 at 7:48 pm
I have a flat source file to import into a table. One column is birthdate, format is DT_DBDate, data is like 08/12/2010
I want to use conditional split, if age<20, the continue, other records ignore.
How can I use ssis to calculate the age<20 by using birthdate column.
Thanks much
December 8, 2011 at 7:59 pm
You might try:
declare @dob datetime,
@age int,
@day datetime
set @day = GETDATE()
set @dob = '1932-04-18'
set @age = datediff(yy,@dob,@day) -
case when @day < dateadd(yy,datediff(yy,@dob,@day), @dob) then 1 else 0 end
select @age
Result:
79
If my memory serves me correctly I think the above code was written by Steve Jones, a long long time ago.
December 9, 2011 at 11:47 am
Thanks, this works in stored procedures or SQL.
What I would like to use is in the SSIS conditional split editor, to filter out their birthdate <20 years old.
The original oracle query is like this, how can I replace it with SQL ones.
ROUND((months_between(SYSDATE,BIRTH_DATE))/12)<20
Thanks
December 9, 2011 at 1:55 pm
In the conditional split you could compare the birth date to today's date minus 20 years.
BirthDate > DATEADD("yy",-20,@[System::StartTime])
Just be sure to watch your boundary conditions. @[System::StartTime] is date/time and I'm guessing birth date is just days.
December 10, 2011 at 5:00 am
I think we can also use derived column transformation and use the datediff() function and system time
to get the age .
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply