472,949 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,949 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 2642
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...
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

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.