The code that can be used to get a date of a particular day of the week in Informatica is listed below with the brief explanation of the same, it can be pasted in the expression transformation.
Let's suppose you need to load the date of coming Friday of this week for all the records. I have considered SYSDATE as the incoming date which can be replaced by your's any system date. The idea used here is simple, first, get the day of the week using TO_CHAR(SYSDATE, 'D') which returns the day of the week; second, based on the day of the week find out how many days we need to add to get the required day, for example, Friday in the code below which is the 6th day of the week starting from Sunday as 1st day; third and final step, use ADD_TO_DATE inbuilt Informatica function to add the required days in the provided date to get the date of the particular day. Another point to consider here, ADD_TO_DATE function accepts integer values only to add so explicitly or implicitly need to change the adding part to an integer, TO_INTEGER is used below for the same purpose. Hope it will be beneficial to you.
ADD_TO_DATE( SYSDATE, 'DD',
TO_INTEGER(
DECODE(TO_CHAR(SYSDATE, 'D'),
'1','5',
'2','4',
'3','3',
'4','2',
'5','1',
'6','0',
'7','6'
)
)
)
No comments:
Post a Comment