Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to calculate Fiscal year based on date

2823391May 9 2011 — edited Mar 20 2013
HI all,

I have a sql statement which simply queries a single table. The table contains an 'effective date' i.e. to_date('01/09/2010', 'dd/mm/yyyy').

I am creating a view based on this query and want to append a psedo column with the dates fiscal year! the fiscal year we are using is the 01/08/.... tot he 31/07/....

I have been trying a few things and found this example on the net which i have been pkaying with, but am completelty clueless as to where the 83days comes in??

select 'FY'||trunc(trunc(to_date('01/09/2010', 'dd/mm/yyyy') + interval '83' day), 'Y') from dual;

I would be really interested to see how you think this can be done.

Thanks

Comments

843789
1) You never told us what error you were getting.

2) Your commented out code and you getInput() method do different things.
Take a look at what the variables "one" and "two" are both cases.
I think you will see that given the same inputs they are not the same in both cases.
(I mean that the value of "one" is different between the two cases.)
843789
I'd say the problem is that you're reading the file names, creating Scanners for them, returning the Scanners, and then trying to get the filenames back from the Scanners. If all you really need is the filename, then the intermediary Scanners are unnecessary.

Either that or you should be using those Scanners in your compare method rather than trying to send it filenames.

Edited by: staphen on Oct 21, 2009 7:37 AM
843789
sorry i forgot. I get this error:
Exception in thread "main" java.io.FileNotFoundException: java.util.Scanner[delimiters=\p{javaWhitespace}+][position=0][match valid=false][need input=false][source closed=false][skipped=false][group separator=\,][decimal separator=\.][positive prefix=][negative prefix=\Q-\E][positive suffix=][negative suffix=][NaN string=\Q?\E][infinity string=\Q?\E] (File name too long)
	at java.io.FileInputStream.open(Native Method)
	at java.io.FileInputStream.<init>(FileInputStream.java:106)
	at java.util.Scanner.<init>(Scanner.java:621)
	at Ch6pp2.compareTwoFiles(Ch6pp2.java:57)
	at Ch6pp2.main(Ch6pp2.java:14)
843789
to johndjr: I don't understand what you mean when you say: "Take a look at what the variables "one" and "two" are both cases.
I think you will see that given the same inputs they are not the same in both cases".
(I mean that the value of "one" is different between the two cases.)

to staphen: what intermediary Scanners ?
843789
baudits wrote:
to staphen: what intermediary Scanners ?
To clarify, your first method call grabs a filename from System.in using tastatur, then creates an (intermediary) Scanner, and returns it. You then proceed to use the (intermediary) Scanner's toString() method to get the filename so you can send them to your second method. If you plan on sending filenames to your second method, then there's no reason to use the intermediary Scanners. If you plan to use the Scanners returned from the first method in your second method, then you will need to modify your second method.
843789
Im planning to send filenames to the second method compareTwoFiles(). So if I don't need the intermediary Scanners how do I prompt the user to type in a file. I don't know how i else can do that. What do you suggest?

Edited by: baudits on Oct 21, 2009 8:13 AM
843789
baudits wrote:
Im planning to send filenames to the second method compareTwoFiles(). So if I don't need the intermediary Scanners how do I prompt the user to type in a file. I don't know how i else can do that. What do you suggest?

Edited by: baudits on Oct 21, 2009 8:13 AM
Notice that I didn't specify tastatur as being one of the intermediary Scanners. Also, think about what you're sending to your compare method (you already told me you're sending filenames), then decide what you need to return from your getInput() method.
843789
baudits wrote:
to johndjr: I don't understand what you mean when you say: "Take a look at what the variables "one" and "two" are both cases.
I think you will see that given the same inputs they are not the same in both cases".
(I mean that the value of "one" is different between the two cases.)
In the code that you commented out you did this
//it works with this code for input. but only if you know the exact name to type
System.out.println("Enter a first file name: ");
Scanner tastatur = new Scanner(System.in);
String one = tastatur.next();
but in the code that does not work you did this
Scanner input1 = getInput(tastatur);
String one = input1.toString();
What is the one in each of these cases?
If you can not figure it out, try printing them out.

Also here's a hint, I don't think that Scanner.toString() does what you think it does.
843789
Thanks for the help both of you. I finally got the code to do what i want. Sometimes you just get blocked on one solution. You look at it one way and just want to solve it that way. Probably because it worked when you did something similar.
1 - 9
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Apr 17 2013
Added on May 9 2011
5 comments
21,748 views