Page 1 of 1

date - 1 day transformationm

Posted: Mon Aug 12, 2013 12:11 pm
by times29
Hi,
My dates are coming as varchar format as 20100503 i want to "%yyyy%mm%dd" and do -1 day too somehow -1 day is not working in syntax below please advise.

Thanks


IF IsValid("date", DSLink19.HRP1001_BEGDA -1, "%yyyy%mm%dd")
THEN StringToDate(DSLink19.HRP1001_BEGDA -1 ,"%yyyy%mm%dd")
ELSE StringToDate("00000101","%yyyy%mm%dd")

Posted: Mon Aug 12, 2013 1:14 pm
by jwiles
That is not the proper way to modify a date. Your source will be converted to a simple integer, then the math performed, then the outer functions performed. While probably most dates might work, several would not--for example, 20100501 - 1 = 20100500, which would not be a valid date.

Take a browse through the date and time functions available for parallel transformers. They are documented in the information center and the production documentation for the version of DataStage you are using. A few possibilities are DateFromDaysSince, DateOffsetByComponents and DateOffsetByDays

IS 9.1: Date and Time Functions
IS 8.7: Date and Time Functions

Regards,

Posted: Mon Aug 12, 2013 2:36 pm
by chulett
ps. And there was no year zero, so your ELSE is invalid.