Date: User Defined Functions Library
Posted by: Raza Khan
A library of date related User Defined functions that can be really handy for PowerCenter Developers.
Overview
User-defined functions extend the PowerCenter transformation language. You can create and manage user-defined functions with the PowerCenter transformation language in the Designer. You can add them to expressions in the Designer or Workflow Manger to reuse expression logic and build complex expressions. User-defined functions are available to other users in a repository. User Defined Date functions : The attached download file has set of Date related user defined functions. The list is given below. IsLeapYear : Takes date as an argument and returns 1 if given year is a LeapYear, 0 if given year is not a Leap Year. Quarter : Takes Date as an argument and returns value of the quarter e.g. Q1,Q2,Q3,Q4. Year_Quarter : Takes Date as an argument and returns value of the quarter e.g. YYYY-Q1,YYYY-Q2,YYYY-Q3,YYYY-Q4. Next_Quarter : Uses Sysdate/date and returns value of next quarter in Q1,Q2,Q3,Q4 format. Prev_Quarter : Uses Sysdate/date and returns value of previous quarter in Q1,Q2,Q3,Q4 format. Quarter_First_Day : Takes Date as an argument and returns date of first day of given quarter. Quarter_Last_Day : Takes Date as an argument and returns date of last day of current quarter. Hours : Takes date as an argument and returns the hour portion of a time in 12 hour format. Hours24 : Takes date as an argument and returns the hour portion of a time in 24 hour format. Minutes : Takes date as an argument and returns the minutes portion of a time. MonthDay : Takes date as an argument and returns MonthDay (e.g. 1,2,?12, 13, ?.30,31). Month : Takes date as an argument and returns the month number given the date (e.g. 1,2,?,11,12). Year : Takes date as an argument and returns the year from the given date (e.g. 1945, 2012 etc..). NextWeekday : Takes date as an argument and returns the date of the specified day of the weekday soonest after the source date. PreviousWeekday : Returns the date of the specified day of the week most recent before the source date. For example, Saturday and Sunday are not counted in Weekday. Yearday : Takes date as an argument and returns the YearDay. E.g. (1,2,3,?,365). Yearweek : Takes date as an argument and returns the YearWeek. E.g. (1,2,3?,52). Days_Between : Takes two days as arguments and returns the no. of days in between. Business_Days_Between : Takes two days as arguments and returns the no. of business days in between. First_monday : Takes date as an argument and returns the date of first Monday of the given month. Last_Monday : Takes date as an argument and returns the date of last Monday of the given month.
Features
- Informatica PowerCenter 9.1 or above