[b]Code piece[/b]: TRUNC(ADD_MONTHS(TO_DATE(SUBSTR(INPD, 1,4), 'YYYY'), 3 * TO_NUMBER(SUBSTR(INPD,-1,1)))-1, 'MM')
1) [b]SUBSTR(INPD, 1,4)[/b]: Beginning at the first character of INPD, take the ensuing four characters (yielding the 4-digit year).
2) [b]TO_DATE(...'YYYY')[/b]: Translate the 4-digit year into a DATE expression. (Since there are neither month nor day values, default the resulting DATE expression to January 1 of the year.)
3) [b]SUBSTR(INPD,-1,1)[/b]: Beginning at the rightmost (i.e., "-1") digit/character of INPD, take the ensuing 1 character (yielding the quarter number). (Note: when using negative start values, the default length is "all characters from the start position to the right end of the value," therefore, the ",1" is optional since we want that one character.)
4) [b]TO_NUMBER(...)[/b]: Transform the one-character quarter into a NUMBER. (Note: character string contains a valid number, and that string is involved in an arithmetic expression, Oracle performs the transformation by default, therefore this function, in this case, is optional.)
5) [b]3 * ...[/b]: Adjust the quarter number to a month number.
6) [b]ADD_MONTHS(<January 1, given year>, <month number>)[/b]: Advance from the beginning of the year, to the month that begins the quarter.
7) [b]TRUNC(...,'MM')[/B]: From the DATE that results from the above ADD_MONTHS function, strip off all DATE/TIME components back to the beginning of the month, i.e. Midnight on the first day of the month.