Get Date Range in tMap component

One Star

Get Date Range in tMap component

Hi,
Currently I have designed one of the job where I am taking record from one of the view present on SQL server and putting into Mysql table. I need the data from 1st Jan 2013 to 31st Dec 2013. So, I have taken tMap and created one variable.
I am using below condition to filter the data.
row1.Defect_Reported_Detected_Date >= isDate("yyyy-mm-dd","2013-01-01") &&
row1.Defect_Reported_Detected_Date <= isDate("yyyy-mm-dd","2013-12-31")
My job design is tMSSQL_input-->tMap-->tMySQL_Output
While running the job, I am getting error as "the method isDate(String,String) is undefined....."
Please let me know the exact way of filtering data or is there any other component available. (excep tfileterrow. I have tried already)
Thanks,
Sisir
One Star

Re: Get Date Range in tMap component

Try this :
SimpleDateFormat ft = new SimpleDateFormat ("yyyy-MM-dd");
Date startDate = ft.parse("2013-01-01");
Date endDate = ft.parse("2014-01-01");
if ( row1.Defect_Reported_Detected_Date.compareTo(startDate) >= 0
&& row1.Defect_Reported_Detected_Date.compareTo(endDate) < 0 ) {
// do what you want
}
One Star

Re: Get Date Range in tMap component

Hi,
Thanks for your quick response. I am restricting data coming from source system i.e one of the view in sql server. So, my source is sql server view. Through tMap I am trying to restrict. After mapping from source with target(MySQL) through tMap, I am using an expression where I have written the below code.
row1.Defect_Reported_Detected_Date >= isDate("yyyy-mm-dd","2013-01-01") &&
row1.Defect_Reported_Detected_Date <= isDate("yyyy-mm-dd","2013-mm-dd")
Is it possible I can write the piece of code you sent, anywhere in tMAP?
Also My purpose is to get 1 year data from source. I need to filter this out.
Please let me know if any other method/component is available.

Thanks,
Sisir
One Star

Re: Get Date Range in tMap component

Why don't you filter the data when you query the view?
Nevertheless, you can put my code in the expression filter in tMap for the output.
But where did you put yours ?
One Star

Re: Get Date Range in tMap component

Thanks.
I restricted the data by modifying the query. Data was coming from SQL server view, and column used is
Defect Reported/Detected Date. So it was not recognizing. I managed to do that as below:
WHERE YEAR()=YEAR(GETDATE())

Regards,
Sisir