Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Fiscal Year Date Query

Posted on 2006-07-10
4
Medium Priority
?
1,979 Views
Last Modified: 2011-10-03
I need to run a query against a date field in Oracle 9i which determines whether the date within the current Fiscal Year.  (Oct-Sept).

How would I do that?  What's the eaisiest, portable way?
0
Comment
Question by:lcor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 800 total points
ID: 17075092
date functions are not portable as of today. every database has it's own function names.

so, to be portable, you have only 1 solution:
 create a table with 3 (4) columns

* start_date
* end_date
* fiscal_year_display
* key_field

I guess the rest should be obvious, apart from the decision how to fill this table (I use 100 years and supply a button in the application that allows to add/edit rows for the future
0
 
LVL 14

Assisted Solution

by:sathyagiri
sathyagiri earned 600 total points
ID: 17075127
0
 
LVL 44

Assisted Solution

by:Arthur_Wood
Arthur_Wood earned 600 total points
ID: 17075528
here is a 'trick' which will return the correct fiscal year, without the need to add a new table to do the conversion.

what you want to do is to ADD 3 months to the actual date, and then take the Year of the result (the three months will effectively advancce OCTOBER of the current year to JANUARY of the FOLLOWING year, and the YEAR function will then return the 'correct Fiscal Year', as the Year to which the follong January belongs).  You do this only to get the Fiscal Year of the data, not to actually modify the dates in any way.

Select <Date_Field>,TO_CHAR(Add_Months(<DATE_Field>, 3), 'YYYY') as Fiscal_Year from YourTable

Change <Date_Field> to the name of the Date field in your table.

AW
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17075586
AW: your trick is not portable :-)
to_char, add_months do not exist in SQL Server and MySQL (to name only these)...
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Your data is at risk. Probably more today that at any other time in history. There are simply more people with more access to the Web with bad intentions.
What we learned in Webroot's webinar on multi-vector protection.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question