473,385 Members | 1,372 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,385 software developers and data experts.

Fiscal year search

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 30) for the year
given. The table looks like this

Bill Table
id_Num bill_date bill_amount
23 7/1/2005 500.00
33 12/2/2005 600.00
44 3/3/2006 700.00

I have tried

Select Bill.id_num, Bill.bill_date, Bill.bill_amount
from Bill
where Bill.bill_date BETWEEN 7/1/ + @year and 6/30/ + (@year +1)

Plus a variety of other fruitless concoctions....but nothing seems to
work. Any help would be appreciated.

Nov 29 '06 #1
4 2669
Discovered answer on my own. Thanks anyway.
Twobridge wrote:
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 30) for the year
given. The table looks like this

Bill Table
id_Num bill_date bill_amount
23 7/1/2005 500.00
33 12/2/2005 600.00
44 3/3/2006 700.00

I have tried

Select Bill.id_num, Bill.bill_date, Bill.bill_amount
from Bill
where Bill.bill_date BETWEEN 7/1/ + @year and 6/30/ + (@year +1)

Plus a variety of other fruitless concoctions....but nothing seems to
work. Any help would be appreciated.
Nov 29 '06 #2
Dan
I've got a simlar problem - can you post your solution?
Dan

On Nov 29, 1:50 am, "Twobridge" <Twobri...@gmail.comwrote:
Discovered answer on my own. Thanks anyway.

Twobridge wrote:
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 30) for the year
given. The table looks like this
Bill Table
id_Num bill_date bill_amount
23 7/1/2005 500.00
33 12/2/2005 600.00
44 3/3/2006 700.00
I have tried
Select Bill.id_num, Bill.bill_date, Bill.bill_amount
from Bill
where Bill.bill_date BETWEEN 7/1/ + @year and 6/30/ + (@year +1)
Plus a variety of other fruitless concoctions....but nothing seems to
work. Any help would be appreciated.- Hide quoted text -- Show quoted text -
Nov 29 '06 #3
On 29 Nov 2006 01:28:49 -0800, Dan wrote:
>I've got a simlar problem - can you post your solution?
Dan
Hi Dan,

The best way to solve this is to have a calendar table (see
http://sqlserver2000.databases.aspfa...ar-table.html),
with FiscalYear as one of it's columns.

Second best is to build a date in string format, using a format that is
guaranteed to be unabiguous WRT the order of day and month: yyyymmdd.
For isntance, for a fiscal year that starts on july first:

DECLARE @FiscalYear int
SET @FiscalYear = 2006
SELECT something
FROM sometable
WHERE TheDate >= CAST(@Year AS varchar) + '0701'
AND TheDate < CAST(@Year + 1 AS varchar) + '0701'

You might want to read this as well:
http://www.karaszi.com/SQLServer/info_datetime.asp

--
Hugo Kornelis, SQL Server MVP
Nov 30 '06 #4
Dan

Hi Hugo

Thanks - i'll take a look

Dan
On Nov 30, 9:13 pm, Hugo Kornelis
<h...@perFact.REMOVETHIS.info.INVALIDwrote:
On 29 Nov 2006 01:28:49 -0800, Dan wrote:
I've got a simlar problem - can you post your solution?
DanHi Dan,

The best way to solve this is to have a calendar table (seehttp://sqlserver2000.databases.aspfaq.com/why-should-i-consider-using...),
with FiscalYear as one of it's columns.

Second best is to build a date in string format, using a format that is
guaranteed to be unabiguous WRT the order of day and month: yyyymmdd.
For isntance, for a fiscal year that starts on july first:

DECLARE @FiscalYear int
SET @FiscalYear = 2006
SELECT something
FROM sometable
WHERE TheDate >= CAST(@Year AS varchar) + '0701'
AND TheDate < CAST(@Year + 1 AS varchar) + '0701'

You might want to read this as well:http://www.karaszi.com/SQLServer/info_datetime.asp

--
Hugo Kornelis, SQL Server MVP
Dec 2 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

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...
1
by: rkohon | last post by:
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...
2
by: Sund via AccessMonster.com | last post by:
I do fair amount of data analysis using access pivot tables and charts. Can any body suggest a method to run the queries based on accounting month and Accounting year.As an example: I want to...
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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.