Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Fiscal Year Date Query

Posted on 2006-07-10
4
Medium Priority
?
1,981 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
  • 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

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

810 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