Page 1 of 1

Calculation in Stage Variable

Posted: Wed Apr 22, 2015 3:02 pm
by sam334
All,
I need to do a calculation in transformer. Kind of confused.

We have data in below format:

ID,DATE,STATUS
A,20150228,Active
B,20150228,Active

Now, if the process runs on March 31st, and if current date is more than DATE+31days then change status to Expired. So, if process runs on 2015-03-15 and as DATE is not 20150228+31 days, then it should be active.

Thanks for your help.

Posted: Wed Apr 22, 2015 3:11 pm
by ray.wurlod
Convert your date string into an internal format date using StringToDate() function, then to the number of days from a given day zero - from which you can perform "day arithmetic".

Posted: Wed Apr 22, 2015 3:11 pm
by chulett
Sounds like a job for the DaysSinceFromDate function.

Posted: Wed Apr 22, 2015 3:17 pm
by sam334
Thanks Ray and Craig. But the source table data type is date, then we don't need to use STRINGTODATE right?

Posted: Wed Apr 22, 2015 9:23 pm
by chulett
Correct... check the function I posted, it returns the number of days between two dates.

Posted: Thu Apr 23, 2015 10:58 am
by sam334
Perfectly worked. Many thanks....