I am new to JavaScript and need some ideas, suggestions, or code snippets.
I have a form which requires the end user to put in a date for required items. I need javascript function to run on this date supplied by end user and for it to populate another area of the form with the Fiscal Year that this will be needed in.
Example: User populates form field with 25-SEPT-07 we need the the Quarter required to immediately poplate this format= 3QFY07.
Our Fiscal Year runs as follows:
Jan-Mar = 1Q
Apr-June = 2Q
July-Sept = 3Q
Oct-Dec = 4Q
The entry date can be todays date, 07 year, 08 year and beyond so the function has to pickup on the year intuitevly. :(
I think an if, then, else approach is what I need just not sure how to get started or where for that matter.
Thank you in advance for any help, suggestions or code.
Regards,
Robert
I have attempted to use PL/SQL code:
Expand|Select|Wrap|Line Numbers
- CREATE OR REPLACE FUNCTION fn_no_of_quarters(p_start_date DATE,p_end_date DATE)
- RETURN NUMBER
- IS
- l_start_date DATE;
- l_end_date DATE;
- q NUMBER := 0;
- l_adjustment NUMBER := 0;
- BEGIN
- l_start_date := p_start_date;
- l_end_date := p_end_date;
- LOOP
- dbms_output.put_line('inside loop for q ='||q);
- l_start_date := add_months(l_start_Date,3);
- dbms_output.put_line('l_start_date ='||l_start_date);
- IF l_start_date <= l_end_date
- THEN
- q := q+1;
- ELSE
- l_start_date := add_months(l_start_Date,-3);
- EXIT;
- END IF;
- END LOOP;
- dbms_output.put_line('l_start_date ='||l_start_date);
- dbms_output.put_line('l_end_Date ='||l_end_Date);
- IF TO_CHAR(l_start_date,'YYYY') = TO_CHAR(l_end_Date,'YYYY')
- THEN
- SELECT to_char(l_end_Date,'Q') - to_char(l_start_date,'Q')
- INTO l_adjustment
- FROM dual;
- l_adjustment := l_adjustment +1;
- ELSE
- l_adjustment := 2;
- END IF;
- dbms_output.put_line('l_adjustment ='||l_adjustment);
- q := q + l_adjustment;
- RETURN q;
- END;