473,386 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Fiscal Year Function with JavaScript

1
Hello all,
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
  1. CREATE OR REPLACE FUNCTION fn_no_of_quarters(p_start_date DATE,p_end_date DATE)
  2. RETURN NUMBER
  3. IS
  4. l_start_date DATE;
  5. l_end_date DATE;
  6. q NUMBER := 0;
  7. l_adjustment NUMBER := 0;
  8. BEGIN
  9. l_start_date := p_start_date;
  10. l_end_date := p_end_date;
  11.  
  12. LOOP
  13. dbms_output.put_line('inside loop for q ='||q);
  14.  
  15. l_start_date := add_months(l_start_Date,3);
  16. dbms_output.put_line('l_start_date ='||l_start_date);
  17.  
  18. IF l_start_date <= l_end_date
  19. THEN
  20. q := q+1;
  21. ELSE
  22. l_start_date := add_months(l_start_Date,-3);
  23. EXIT;
  24. END IF;
  25. END LOOP;
  26.  
  27. dbms_output.put_line('l_start_date ='||l_start_date);
  28. dbms_output.put_line('l_end_Date ='||l_end_Date);
  29.  
  30. IF TO_CHAR(l_start_date,'YYYY') = TO_CHAR(l_end_Date,'YYYY')
  31. THEN
  32. SELECT to_char(l_end_Date,'Q') - to_char(l_start_date,'Q')
  33. INTO l_adjustment
  34. FROM dual;
  35.  
  36. l_adjustment := l_adjustment +1;
  37. ELSE
  38. l_adjustment := 2;
  39. END IF;
  40.  
  41. dbms_output.put_line('l_adjustment ='||l_adjustment);
  42. q := q + l_adjustment;
  43.  
  44. RETURN q;
  45. END;
  46.  
  47.  
Nov 10 '06 #1
1 7562
acoder
16,027 Expert Mod 8TB
Take the data input from the user, dateInput and split it using dateInput.split("-"). Now dateInput[1] would be "SEPT" and dateInput[2] "07". Keep an array that has all the months mapped out to the quarters, e.g. Fiscal["JAN"]="1Q", so Fiscal[dateInput[1]] would give you "3Q". That's all that is needed. Now just concatenate the strings: Fiscal[dateInput[1]] + "FY" + dateInput[2].
May 28 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: MissiMaths | last post by:
This isn't really an access question as I can write the code myself(I hope) but need to know how the start of the financial year is worked out. If someone knows the rules or an algorithm, I would...
3
by: haydn_llewellyn | last post by:
Hi, My company runs on a fiscal calendar that starts on the first monday in July, and is based on a 13 week quarter (4 weeks, 4 weeks, 5 weeks). What I need, is a way of relating Date() to the...
2
by: JohnC | last post by:
This fantastic expression was posted by Duane Hookom. I have no idea how it works but it displays the fiscal year and quarter for FY starting on October 1. =Format$(DateAdd("q",1,),"\Qq...
4
by: Twobridge | last post by:
Hi I am trying to perform a search that will return records based on a fiscal year search of the bill_Date. The user gives the year then I want to search based on the fiscal year (July 1 - June...
4
by: ltazz | last post by:
How can i make it so that Access will Recognize the fiscal year 07 start at 1 oct 2006, and end 30 Sep 2007? i know its possible, however cant figure it out. Thanks for the help in advance you...
3
by: shiznaw | last post by:
I got another problem while working on this database for the Univ. The Form.viewreports has several radial button options so that the user can view a Report for several periods--like a day, a...
6
craigfr
by: craigfr | last post by:
I am making a graph comparing last year's defect data with YTD defect data. Our fiscal year starts Nov.1 and ends Oct.31. To get the YTD, I started used a simple date serial criteria: Between...
2
by: RZ15 | last post by:
Hi guys, I'm really drawing a blank here for how to deal with fiscal months in my monthly sales/receipts reports. My issue is that calculating the months is not as simple as saying 'if the invoice...
1
by: xtremebass | last post by:
Hello Bytes, i have a calender program which is created by using Javascript. when i execute that program using Internet Explorer,it works properly but when i tried in Mozilla firefox it didnt...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.