date - 1 day transformationm

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
times29
Premium Member
Premium Member
Posts: 202
Joined: Mon Sep 22, 2008 3:47 pm

date - 1 day transformationm

Post 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")
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post 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,
- james wiles


All generalizations are false, including this one - Mark Twain.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

ps. And there was no year zero, so your ELSE is invalid.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply